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

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,

#include <stdio.h>

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

int main (int argc, const char * argv[]) {
	char pass1, pass2, pass3;
	scanf("%c,%c,%c", &pass1, &pass2, &pass3);
	if (&pass1 == "p", &pass2 == "w", &pass3 == "d"); 
	else {
void Hello( void ) {
	printf("Welcome to Unix!\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's Avatar
Member Since: Apr 26, 2008
Location: Belgium
Posts: 2,290
McBie is a name known to allMcBie is a name known to allMcBie is a name known to allMcBie is a name known to allMcBie is a name known to allMcBie is a name known to allMcBie is a name known to all
Mac Specs: 2013 MBA 13" - 10.9.3 & iPad - iOS 5.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'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.


McBie beat me to it, Cheers
QUOTE Thanks

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

All times are GMT -4. The time now is 12:18 PM.

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

Welcome to

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?