getting error while compiling c programs

Asked by pANonca

I am new to Linux os and i installed ubuntu juanty two days before.
i have installed build essential packages and other packages required to compile c code. But while compiling simple c program (which only prints the message ) i am getting error.
the code is:-

#include<stdio.h>
int main
{
 printf("this is sit\n");
return 0;
}

i'm getting the below error:-

sample.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token

so tell me what to do ???

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

your main line is incorrect

you have missed the arguments from main

instead of

int main

change it to

int main (void)

incidentally, if you use

void main (void)

you dont need the pointless

return 0

at the bottom

Can you help with this problem?

Provide an answer of your own, or ask pANonca for more information if necessary.

To post a message you must log in.