Thread: simple printf wont compile...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    20

    simple printf wont compile...

    i'm trying to do this one exercise in a book where it asks you to replace user input of blanks tabs and backspaces with the words "blanks" "tabs" and "backspaces. but somehow this printf wont compile...

    Code:
    #include <stdio.h>
    
    #define IN 1
    #define OUT 0
    
    
    
    int main(void)
    {
        int c, state;
        state = OUT;
    
        while((c = getchar()) != EOF){
              putchar(c);
              if(c == ' ')
                 printf("blankz");
              if(c == '\t')
                 printf("tabz);
              if(c == '\b')
                 printf("backspacez");
            }
    }
    the error is in printf("backspacez"); and it says the "tabz" printf has an error too but NOT the printf("blankz"); for some reason...

    Error message:
    cpp:20:unterminated string or character constant
    cpp:18ossible real start of unterminated constant

    i meant to say 18 colon but it makes that face lol. o and im using
    C-Free 3.5

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    I hope no one replies Ive just deleted my post cause this is a simple error and I can't believe this guy is asking this I mean he isn't reading his own code...

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    7
    //printf("tabz);

    You're missing the second " to close the string.

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Quote Originally Posted by isaac_s
    //printf("tabz);

    You're missing the second " to close the string.
    Man look
    error.c: In function ‘main’:
    error.c:18: error: missing terminating " character
    error.c:19: error: syntax error before ‘if’
    error.c:22: warning: control reaches end of non-void function
    error.c:22:2: warning: no newline at end of fil
    He isn't reading the compiler warnings...

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    903
    Can't you see he uses a ........ty IDE and this error yyou have isn't in his compiler errors. If he's writing in a regular text app like Wordpad or if his IDE doesn't support colored syntax, I can understand he didn't see this as he is a beginner.

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Quote Originally Posted by Desolation
    Can't you see he uses a ........ty IDE and this error yyou have isn't in his compiler errors. If he's writing in a regular text app like Wordpad or if his IDE doesn't support colored syntax, I can understand he didn't see this as he is a beginner.
    Man gcc output mentions the error look...
    Hey wich IDE are you using i_can_do_this?

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    903
    i meant to say 18 colon but it makes that face lol. o and im using
    C-Free 3.5
    There is his IDE.

  8. #8
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Quote Originally Posted by Desolation
    There is his IDE.
    Just checked C-Free has highlight btw wtf is it called C-Free if it is in fact shareware :P

  9. #9
    Registered User
    Join Date
    Jul 2006
    Posts
    20
    o my bad.... i guess it was the tabs problem but it was weird cause the compiler said there was an error in the "backspace if "statement .

  10. #10
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    Quote Originally Posted by i_can_do_this
    o my bad.... i guess it was the tabs problem but it was weird cause the compiler said there was an error in the "backspace if "statement .
    It's not because a compiler gives an error on line 10 that the error will be on line 10, it can even be on line 9 or .....

    Therefore, compile after every new chunk/function/... of code that you write. It will save you alot of time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  2. menu problem!!! need U R G E N T help!!!
    By catcat28 in forum C Programming
    Replies: 16
    Last Post: 11-19-2007, 01:32 PM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Azbia - a simple RPG game code
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 05-03-2002, 06:59 PM