Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iMasterWeb

macrumors regular
Original poster
Mar 15, 2009
158
0
What does this mean? I have 20 of them and they're all the same. Here's my code if it matters. I'm only posted the part where the errors are appearing.

Code:
if(rjoke == 1)
	    printf("Two hunters are out in the woods when one of them collapses. He's not breathing and his eyes are glazed. The other guy whips out his cell phone and calls 911. 'I think my friend is dead!' he yells. 'What can I do?'  
The operator says, 'Calm down. First, let's make sure he’s dead.' 
There's a silence, then a shot. Back on the phone, the guy says, 'Okay, now what?'");
			
if(rjoke == 2) 
   printf("Why Don't Blind People Like To Sky Dive?\n
Because It Scares The Dog");
		
if(rjoke == 3) 
   printf("A man is walking in a graveyard when he hears the Third Symphony played backward. When it's over, the Second Symphony starts playing, also backward, and then the First. 'What's going on?' he asks a cemetery worker. 'It's Beethoven,' says the worker. 'He's decomposing.'");
		
if(rjoke == 4) 
   printf("What Do You Call Four Bullfighters In Quicksand?\n
   Quatro Sink");
	
if(rjoke == 5) 
   printf("What Do You Call a Boomerang That Doesn't work?\n
   A Stick");
		
if(rjoke == 6) 
   printf("How Do Crazy People Go Through The Forest?\n
   They Take The Psycho Path");
		
if(rjoke == 7) 
   printf("What is the difference between Mechanical Engineers and Civil Engineers?\n
Mechanical Engineers build weapons.\n
Civil Engineers build targets.");

I'm putting a joke feature in my code, if your wondering. There's an error after every line that is being printed on the screen.

e.g.:
Code:
printf("text text text
// error
text text");
// error

Thanks for all of your help!
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
If a string is continuing onto another line, you must add a backslash right before the new line starts, like:
Code:
printf("Line 1\n \
       Line 2\n");
 

kpua

macrumors 6502
Jul 25, 2006
294
0
You can also do this:

Code:
printf("Line 1\n"
       "Line 2\n");

... or just don't have an actual new line in the code. The \n is all that is necessary for it to print out.

Or even better, read the strings from a file that are already formatted correctly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.