For some reason while compiling my source I get a parce error at the end of my code. the only thing on the line is the final bracket I will put the int main( ) below can someone tell me why this parse error keeps happening it is the only line in my source that has and error and I want to get to the debugging process but I need to get past this and I am stumped. Thanx for your help in advance.
int main();
{ char k;
cout<<"********Welcome to EXPERMENT PROGRAM 1 *********************";
cin>>k;
if (k=(char)"2")
{ login();
}
else
{ signup();}
} (<----------Here On this line is the error it is a 66
parse error at end of input)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well from what i can see, the reason you are getting a parser error is because you have a semicolon (;) at the end
of ' int main()'. Simply remove it and it should work fine.
PS:
Btw, couldn't help to notice but, on the line:
if(k=(char)"2")
you are assigning the value to to the variable 'k', not testing for equality. Im guessing you want to see if
the user has entered 2, and the do the login code.
Use the '==' operator instead.
Just wanted to point that out. Hope this helps you out!
Good Luck!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2002-08-14
if(k=(char)"2")
assignment that should be
if(k==(char)"2")
like jackrabbit said, but "2" is a pointer to a string containing 2. You are casting the pointer to char, so it won't work as you want. It should be:
if(k=='2')
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For some reason while compiling my source I get a parce error at the end of my code. the only thing on the line is the final bracket I will put the int main( ) below can someone tell me why this parse error keeps happening it is the only line in my source that has and error and I want to get to the debugging process but I need to get past this and I am stumped. Thanx for your help in advance.
int main();
{ char k;
cout<<"********Welcome to EXPERMENT PROGRAM 1 *********************";
cin>>k;
if (k=(char)"2")
{ login();
}
else
{ signup();}
} (<----------Here On this line is the error it is a 66
parse error at end of input)
Hello John.
Well from what i can see, the reason you are getting a parser error is because you have a semicolon (;) at the end
of ' int main()'. Simply remove it and it should work fine.
PS:
Btw, couldn't help to notice but, on the line:
if(k=(char)"2")
you are assigning the value to to the variable 'k', not testing for equality. Im guessing you want to see if
the user has entered 2, and the do the login code.
Use the '==' operator instead.
Just wanted to point that out. Hope this helps you out!
Good Luck!
if(k=(char)"2")
assignment that should be
if(k==(char)"2")
like jackrabbit said, but "2" is a pointer to a string containing 2. You are casting the pointer to char, so it won't work as you want. It should be:
if(k=='2')