I want to check if user input contains only numbers or not. So, I am using the following code:
for(i = 0; argv[1][i] != NULL; i++) if(!isdigit(argv[1][i])) { printf("Error"); return -1; }
It works well, but I got this warning:
warning: comparison between pointer and integer [enabled by default]
since argv[1][i]
is an integer and NULL
is a pointer. How can I avoid such a warning?
source share