Reputation: 135
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.
Upvotes: 1
Views: 1401
Reputation:
argv is an array of string pointers. You should just change source
and target
to char *
or const char *
instead of arrays and change the code to
source = argv[3];
target = argv[4];
That will make it work. It will also prevent a buffer overflow had you copied the strings into the arrays. It would also mean your app will handle long file paths.
Upvotes: 4
Reputation: 589
Use strcpy() from string.h:
strcpy(source,argv[1]);
strcpy(target,argv[2]);
Upvotes: -1