error: syntax error at "OTHER" token

Discussion in 'Mac Programming' started by iMasterWeb, Jun 21, 2009.

  1. iMasterWeb macrumors regular

    Mar 15, 2009
    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.

    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.

    printf("text text text
    // error
    text text");
    // error
    Thanks for all of your help!
  2. kainjow Moderator emeritus


    Jun 15, 2000
    If a string is continuing onto another line, you must add a backslash right before the new line starts, like:
    printf("Line 1\n \
           Line 2\n");
  3. kpua macrumors 6502

    Jul 25, 2006
    You can also do this:

    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.
  4. iMasterWeb thread starter macrumors regular

    Mar 15, 2009

Share This Page