what is wrong with my program

xzibit2313's Avatar, Join Date: Jun 2009
Light Poster
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
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
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.
0
stylishkishore's Avatar, Join Date: Jun 2009
Go4Expert Member
Quote:
Originally Posted by SaswatPadhi View Post
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?
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
Yeah, you are right !

" " should enclose strings and not “ ”.
0
xzibit2313's Avatar, Join Date: Jun 2009
Light Poster
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
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
Welcome to G4EF, xzibit2313.
0
xzibit2313's Avatar, Join Date: Jun 2009
Light Poster
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
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
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;
}
0
xzibit2313's Avatar, Join Date: Jun 2009
Light Poster
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
0
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
Sure, there are many.

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