Search code examples
ceclipseeclipse-cdt

Undefined reference to 'WinMain@16' C error


I am using Eclipse (C programming) and I have come up with this code but every time I build it, I get the error saying, "Undefined Reference to 'WinMain@16'". I have spent over 2 hours trying to solve this problem but I can't figure out my where my error is. Can anyone help?

This is the code:

#include <stdio.h> 

int main(void)
{
    int input;

    printf("Please enter an integer:\n");
    scanf("%d",&input);
    int temp = input;

    while(input<=temp+10)
    {
        printf("%d ",input);
        input++;
    }

    printf("\n");

    return 0;
}

Solution

  • When you compile or build, files are not automatically saved to disk by Eclipse. But the compiler is using the on-disk files. So maybe you just didn't save the file after you've added the main function.