Jul 10, 2002 #1 Guest_imported New member Joined Jan 1, 1970 Messages 0 What does this do... int main(int argv, char **argc) { char buf[256]; strcpy(buf,argc[1]); exit(1); }
What does this do... int main(int argv, char **argc) { char buf[256]; strcpy(buf,argc[1]); exit(1); }
Jul 10, 2002 #2 olded Programmer Joined Oct 27, 1998 Messages 1,065 Location US Eddie: All it does is copy your first command line argument into character variable buffer. By convention (although you've done nothing wrong syntax wise), argc is the argument count and argv is the pointer to a char pointer: void main(int argc, char **argv) { char buf[256]; if(argc != 2) { printf("arg count error\n" exit(1); } strcpy(buf,argv[1]); printf("buf is %s\n", buf); exit(0); } Regards, Ed Upvote 0 Downvote
Eddie: All it does is copy your first command line argument into character variable buffer. By convention (although you've done nothing wrong syntax wise), argc is the argument count and argv is the pointer to a char pointer: void main(int argc, char **argv) { char buf[256]; if(argc != 2) { printf("arg count error\n" exit(1); } strcpy(buf,argv[1]); printf("buf is %s\n", buf); exit(0); } Regards, Ed