Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just curious

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
What does this do...

int main(int argv, char **argc) {

char buf[256];
strcpy(buf,argc[1]);
exit(1);

}
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top