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

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -