C++ - problem with *char[]
void main(int argc, *argv[])
{
if(argv[2]==''q'')
}
The problem here was that I couldn''t convert the *char to an int nor to char type.
When I tried:
if(*argv[2]==''q'')
the program was compiled but when program crashed at execution.
I''d like to know how to use or store the seperate values in the array.
For example:
char a = argv[2];
The Department of Next Life - Get your Next-Life Insurance here!
char a = argv[2][0];
char a = *argv[2];
so:
will work, but I will bet you money that argc < 3 when it crashed on you.
char a = *argv[2];
so:
void main(int argc, *argv[])
{
if(*argv[2]==''q'')
...
}
will work, but I will bet you money that argc < 3 when it crashed on you.
October 19, 2000 06:35 PM
Thanks, but the program still crashes.
Argc was larger than 3 when it did.
#include
using namespace std;
void main(int argc,char *argv[])
{
if(*argv[2]==''q''){cout<<"argv[2] is q";}
}
It says the program has performed an illegal operation.
Argc was larger than 3 when it did.
#include
using namespace std;
void main(int argc,char *argv[])
{
if(*argv[2]==''q''){cout<<"argv[2] is q";}
}
It says the program has performed an illegal operation.
Why not just do this:
Null and Void
At least I don't know COBOL...
// Stuff ...void main(int argc,char *argv[]) { if(argv[2][0]==''q'') { cout<< "argv[2] is q"; }}[/source]Or this:[source]// Stuff ...#include <string.h>void main(int argc,char *argv[]) { if(strcmp(argv[2],"q")==0) { cout<< "argv[2] is q"; }}
Null and Void
At least I don't know COBOL...
Ok, thanks .
The Department of Next Life - Get your Next-Life Insurance here!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement