Skip to main content
2 of 2
improved information

Summary: See comments in the code , error messages, constants/magic numbers (which has been mentioned before..) and integers


    printf( "\nPlease input the integer you would like to find.\n" );
    scanf( "%d", &N );

/* Should there be some error catching here ? 
   What if the user inputs a string,-1,or 10,000 ?
   get_num_of_ints( arr, r, N, &first, &count ) does do some bounds
   checking, but doesn't emit any error messages.
   Beware, the user can always think of something unusual.
*/

    int a = get_num_of_ints( arr, r, N, &first, &count );

    /* If the function returns -1 then the value is not found.
// This is different to the user inputting something out of range

Is it worth making -1 a const ?

const int EXIT_CODE = -1;  // or
const int SUCCESS = -1;  

// I forgot it was C so maybe

#define EXIT_CODE -1       // or
#define SUCCESS -1         // or whatever -1 equals ?

If you were going to use C++, perhaps less pointers ?

Is it worth defining what size and sign your integers are going to be eg u/int32_t, u/int64_t etc ? Available in stdint.h