Working on a simple C program I’m stuck with an if test:
int line_number = 0;
if ((line_number >= argv[2]) && (line_number <= argv[4]))
gcc says:
cp.c:25: warning: comparison between pointer and integer cp.c:25: warning: comparison between pointer and integer
What can I do to properly check the range of lines I want to deal with?
Of course it doesn’t work:
argvis a pointer to pointer tochar.. it’s not clear what you want to do but think about thatargv[2]is third parameter andargv[4]is fifth one. But they are ofchar*type (they are strings) so if you want to parse them as integers you should do it using the functionatoi:will parse int that was as third parameter and place it into variable, then you can check whatever you want.