Argc/Argv C Problems
- by Salman
Hey all,
If I have the following code:
main(int argc, char *argv[]){
char serveradd[20];
strcpy(serveradd, argv[1]);
int port = atoi(argv[2]);
printf("%s %d \n", serveradd, port);
The first two arguments to the command line are printed. However, if I do this:
char serveradd[20];
strcpy(serveradd, argv[1]);
int port = atoi(argv[2]);
char versionnum[1];
strcpy(versionnum, argv[3]);
printf("%s %d %s \n", serveradd, port, versionnum);`
The first argument (serveradd) does not print out to the screen and is not being stored... Why is this happening and how can I fix it? Thanks!