If endptr is of type char**, **endptr is not a pointer.
So why does this give me:
Code:
scrap.c: In function ‘main’:
scrap.c:14: warning: comparison between pointer and integer
?
But, if I replace NULL with 0 or '\0', the warning goes away.
(in both gcc 4.1.2 and gcc 3.4.6)
Code:
#include <stdio.h>
int main( int argc, char** argv ) {
if (argc < 4) {
printf ("\nUsage: threshEdges <input_filename> <threshold> "
"<output_filename>\n");
return 0;
}
char **endptr;
long threshold;
threshold = strtol(argv[2], endptr, 10);
printf("**endptr: %d\n", **endptr);
printf("argv[2]: %d\n", threshold);
if (**endptr != NULL) {
printf ("\nUsage: threshEdges <input_filename> <threshold> "
"<output_filename>\n"
"%s is not a valid threshold.\n", argv[2]);
printf("**endptr: %d\n", **endptr);
return 0;
}
return 0;
}