New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

"Expected expression before 'else'" problem


Post Reply New Thread Subscribe

 
Thread Tools
xMrnewb

 
Member Since: May 16, 2010
Posts: 2
xMrnewb is on a distinguished road

xMrnewb is offline
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!
QUOTE Thanks
McBie

 
McBie's Avatar
 
Member Since: Apr 26, 2008
Location: Belgium
Posts: 2,541
McBie is a splendid one to beholdMcBie is a splendid one to beholdMcBie is a splendid one to beholdMcBie is a splendid one to beholdMcBie is a splendid one to beholdMcBie is a splendid one to beholdMcBie is a splendid one to beholdMcBie is a splendid one to behold
Mac Specs: 2013 MBA 13" - OS X 10.10.1

McBie is offline
Why is there a semicolon after the first " if " statement ?

Cheers ... McBie

A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila.
The problem is not the problem. The problem is your attitude towards the problem. You understand ?
QUOTE Thanks
scathe

 
scathe's Avatar
 
Member Since: Jan 12, 2009
Location: Prague, Czech Republic
Posts: 1,096
scathe is a jewel in the roughscathe is a jewel in the rough
Mac Specs: 2,4Ghz 15" unibody

scathe is offline
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
QUOTE Thanks
xMrnewb

 
Member Since: May 16, 2010
Posts: 2
xMrnewb is on a distinguished road

xMrnewb is offline
ahhh thanks alot guys

school boy error =P

greatly appreciated guys thanks again
QUOTE Thanks

Post Reply New Thread Subscribe


« ettercap from source install | Changing entire button background color »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
diagnosing kernel task/CPU problem on Macbook Air nick_harambee Apple Notebooks 9 08-20-2011 08:20 AM
Problem With Keyboard...... mmcltd OS X - Operating System 4 02-02-2010 07:47 PM
Possible faulty CPU thermometer, common problem? dyaballikl Apple Notebooks 6 11-16-2008 01:21 AM
Microsoft Messenger Problem millenium_spike OS X - Apps and Games 4 09-16-2008 02:11 AM
Problem Darwin Server + VLC nanaki Web Design and Hosting 0 03-13-2008 08:27 AM

All times are GMT -4. The time now is 08:44 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?