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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with main's arguments

Status
Not open for further replies.

Vdcss

Programmer
Dec 5, 2001
2
RO
In the following code:
void main(int argc, char *argv[]) {
if (argc == 3 )
if (argv[1] == 'c') { //doesn't work
int m;
m = atoi(argv[2]); //doesn't work
}
}
The parameters are c 201.

The lines marked give me an error. I think I know why but I don't know how to resolve it or how to bypass it...
Can someone help me, please...
 
if (argv[1] == 'c') //doesn't work cause'
argv[1] is char*, use: if( !strcmp(argv[1],"c") )
m = atoi(argv[2]); //This works if you send to cmdLine "myProg.exe c 201".

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top