Search code examples
cargv

warning: assignment makes integer from pointer without a cast ARGV


This is the warning I get.

copyit.c: In function ‘main’:
copyit.c:15: warning: assignment makes integer from pointer without a cast
copyit.c:16: warning: assignment makes integer from pointer without a cast

The lines of code that this corresponds to are the ones that begin with pointers (*).

char source[128],target[128],buffer[512];

if(argc==3) {
*source = argv[1];
*target = argv[2];
}

I just want to assign those two things so I can pass them from the command line like that and I can then use them in my handle (ex: inhandle=open(source,O_RDONLY); Thank you.


Solution

  • Use strcpy() from string.h:

    strcpy(source,argv[1]);
    strcpy(target,argv[2]);