Home > OS >  I am new in C Programming and getting this error
I am new in C Programming and getting this error

Time:12-17

#include<stdio.h>
void display(); //Functon prototype

    int main(){
  
    printf("Initializing display function\n");
      display();
      printf("Display function finished\n");
    return 0;
}

void display(){
    printf("This is display\n");
}

Here is the error message please help me to solve this:-

PS D:\C Tutorial> gcc 05_function.c                                   
}
C:/MinGW/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup 0x39):
undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1
exit status 
PS D:\C Tutorial>

CodePudding user response:

If you are using a text editor without autosave, this can happen.

Try saving your code and running it again.

If you are using VSCode, I'd recommend enabling autosave.

Hope I could help!

CodePudding user response:

This error occurs when we try to compile an empty file. Saving the file and then compiling it will help in this.

  • Related