Michael Hunt
Michael Hunt

Reputation: 1

Output is not shown when trying to run C program

When I try to run this program, my terminal doesn't display anything.

Here is the program:

/* Print a message on the screen*/

#include <stdio.h>

int main()
{
    printf("Hello World.\n");
    return 0;
}

Am I doing anything wrong?

--EDIT--

My antivirus was blocking the execution of the program.

Upvotes: 0

Views: 3039

Answers (2)

S.S. Anne
S.S. Anne

Reputation: 15584

Add a newline to the end of your string (or use puts):

/* Print out a message on the screen*/

#include <stdio.h>

main()
{
    printf("Hello World.\n");
    return 0;
}

Usually compilers will optimize this printf call to puts("Hello, World.").

It is also recommended to declare main as an int (use int main() ...).

Upvotes: 1

Adrien
Adrien

Reputation: 497

When you define a function in C you need to specify the return type. So your main function has to be declared as int main() (because it returns an integer)

Upvotes: 0

Related Questions