Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   what is wrong with my program (http://www.go4expert.com/forums/wrong-program-t17951/)

xzibit2313 12Jun2009 06:12

what is wrong with my program
 
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

SaswatPadhi 12Jun2009 06:38

Re: what is wrong with my program
 
Try this : (It might look same, but after careful observation, you can spot the difference(s) ;))

Code: C

#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.

stylishkishore 12Jun2009 06:53

Re: what is wrong with my program
 
Quote:

Originally Posted by SaswatPadhi (Post 49417)

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?

SaswatPadhi 12Jun2009 07:00

Re: what is wrong with my program
 
Yeah, you are right ! :)

" " should enclose strings and not “ ”.

xzibit2313 12Jun2009 07:01

Re: what is wrong with my program
 
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

SaswatPadhi 12Jun2009 07:05

Re: what is wrong with my program
 
Welcome to G4EF, xzibit2313.

xzibit2313 12Jun2009 07:06

Re: what is wrong with my program
 
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

SaswatPadhi 12Jun2009 07:14

Re: what is wrong with my program
 
LOL, I think you are confused with printf syntax.

Try this :

Code: C

#include <stdio.h>

int main()
{
      printf("\n2+2 = %d", 2+2);
      return 0;
}


xzibit2313 12Jun2009 07:39

Re: what is wrong with my program
 
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

SaswatPadhi 12Jun2009 07:42

Re: what is wrong with my program
 
Sure, there are many.

shabbir mentions them here : http://www.go4expert.com/showthread.php?t=107


All times are GMT +5.5. The time now is 12:12.