1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

what is wrong with my program

Discussion in 'C' started by xzibit2313, Jun 12, 2009.

  1. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    I am a noob
    and this is my first post
    so hello


    and i would like to know if you can tell me what is wrong with my code
    i am just starting c so her is my C program
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        // insert code here...
        printf(“Why does every programmer look like this...\n”);
        printf(“~~\n”);
        printf(“-00-\n”);
        printf(“-\n”);
        printf(“U\n”);
        return 0;
    }
    
    the compiler puts the words
    error: syntax error at 'OTHER' token
    below every
    line that has printf on it
     
  2. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    Try this : (It might look same, but after careful observation, you can spot the difference(s) ;))

    Code:
    #include <stdio.h>
    
    int main(void)
    {
        // insert code here...
        printf("Why does every programmer look like this...\n");
        printf("~~\n");
        printf("-00-\n");
        printf("-\n");
        printf("U\n");
        return 0;
    }
    Copy the exact code above and paste in your IDE and compile it. Tell me the result.
     
  3. stylishkishore

    stylishkishore New Member

    Joined:
    Jun 4, 2009
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Can you please tell me what is the difference between the above and yours code.
    I think " " are the first.And syntax highlight is second one.Am i right?
     
  4. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    Yeah, you are right ! :)

    " " should enclose strings and not “ ”.
     
  5. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    haha i see with the quotes whoops well i wrote the code in a text editor and the i copied it and pasted into the compiler thx tho
     
  6. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    Welcome to G4EF, xzibit2313.
     
  7. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include <stdio.h>
    int main (void)
    {
    	printf("\n2+2= %d”, 2+2");
    	return 0;
    }
    now what is wrong with that code i am trying to add 2+2 and display it
     
  8. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    LOL, I think you are confused with printf syntax.

    Try this :

    Code:
    #include <stdio.h>
    
    int main()
    {
          printf("\n2+2 = %d", 2+2);
          return 0;
    }
     
  9. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Oh I see all I had to do was remove that last quote .
    Thx a bunch I'm sure I'll have many more questions tomarrow

    Are their any good c tutorials on here
     
  10. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
  11. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Instead of a list of hundreeds of beginner tutorials do u know just one that is really good that goes beyond beginner
     
  12. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    I don't think you read the link that I had mentioned, carefully.

    Just after the list, someone posted a similar question.
    And as shabbir answers : "All are good to start with. but the Bjarne Stroustrup's and 21 days are good to look at."

    :)
     
  13. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Do u know of any really good ones because there is a list of about 50 there also do u know one that goes from beginner level and beyond instead of stopping after the basics

    Thx
     
  14. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    O ok and srry for posting my question twice I didn't think it worked the first time
     
  15. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    That's OK.

    I hope learning C won't be difficult for you.
    (We are here to help, if you face any difficulty :))
     
  16. xzibit2313

    xzibit2313 New Member

    Joined:
    Jun 12, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Ok I looked again and noticed that is a c++ book I'm looking for plain original c
     

Share This Page