Hello all. I am making my first hello world program in C, and I have already run into issues.

#include <stdio.h>

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

I am getting two errors when I try to run this.

C:\Users\Wiseguy\Documents\CodeBlocks\firstproject\firstproject.c|4|multiple definition of `main'|

and

obj\Debug\main.o:C:\Users\Wiseguy\Documents\CodeBlocks\firstproject\main.c|5|first defined here|

I feel stupid for posting this, but I am stuck. How do I correct these errors?

Recommended Answers

All 2 Replies

The error message sounds like you have more than one *.c file with main() in the project. Check your project and remove one of the files.

There can be only one main() function in your whole program. It is the function that is called when your program starts executing. If there is more then one main functions delete it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.