"Expected expression before 'else'" problem

Joined
May 16, 2010
Messages
2
Reaction score
0
Points
1
Hello everyone,
I am a newb to programming and have done a few hours of C,
I was writing this program for use as a start up program in Terminal but i got the error message Expected expression before else, when compiling in Xcode,
i had an "if" statement before and there are curly braces at the end of the "if" statement,


Code:
#include <stdio.h>

void Hello( void );
void Failed( void );

int main (int argc, const char * argv[]) {
	char pass1, pass2, pass3;
	
	Hello();
	
	scanf("%c,%c,%c", &pass1, &pass2, &pass3);
	
	getchar();
	
	if (&pass1 == "p", &pass2 == "w", &pass3 == "d"); 
	{
		printf("Continue!\n");
	} 
	else {
		Failed();
	}
}
	
void Hello( void ) {
	printf("Welcome to Unix!\n");
	getchar();
	printf("Password?\n");
}

void Failed( void ) {
	int inf1;
	inf1 = 1;
	printf("Leave now.");
	while (inf1 > 2) {
		printf("Leave now.");
	}
}

any help would be greatly appreciated, thanks!
 
Joined
Apr 26, 2008
Messages
2,963
Reaction score
120
Points
63
Location
Belgium
Your Mac's Specs
iPad Pro 12.9 latest iOS
Why is there a semicolon after the first " if " statement ?

Cheers ... McBie
 
Joined
Jan 12, 2009
Messages
1,096
Reaction score
19
Points
38
Location
Prague, Czech Republic
Your Mac's Specs
2,4Ghz 15" unibody
you've got a semicolon between the if statement and the following code block.

use:
if(){
}
not:
if();{
}

Edit:
McBie beat me to it, Cheers :)
 
OP
X
Joined
May 16, 2010
Messages
2
Reaction score
0
Points
1
ahhh thanks alot guys

school boy error =P

greatly appreciated guys thanks again :D
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top