c - stdlib.h not working as intended with atoi() function -
in program, i'm using atoi() function extract int argv. when use
#include <stdlib.h> i following error:
cachesim.c:20: warning: passing argument 1 of ‘atoi’ incompatible pointer type however, if not include stdlib.h receive no error @ , code functions properly. why this?
#include <stdlib.h> #include <stdio.h> main(int argc, int **argv){
if(argc == 0){ int blk = 32; int i; (i = 1; < argc; i++){ if (strcmp(argv[i], "-b") == 0){ if (i + 1 <= argc - 1) blk = atoi(argv[i+1]); } } } }
change:
main(int argc, int **argv){ to
int main(int argc, char *argv[]){ your former declaration not acceptable declaration main , atoi requires parameter of type char *.
Comments
Post a Comment