0

this is my code

#include<stdio.h>

int main()
{

    printf("I just started");
    return 0;
}

and this is the error

PS E:\coding> cd "e:\coding\" ; if ($?) { gcc tempCodeRunnerFile.c -o tempCodeRunnerFile } ; if ($?) { .\tempCodeRunnerFile }
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • Run preferably [GCC](http://gcc.gnu.org/) with all warnings and debug information, so `gcc -Wall -Wextra -g tempCodeRunnerFile.c -o tempCodeRunnerFile`. BTW, consider installing some Linux distribution (perhaps [Debian](http://debian.org/) or [Ubuntu](http://ubuntu.com/) ...) on your computer. It is much more developer friendly than Windows. – Basile Starynkevitch Oct 09 '20 at 05:29
  • Please indent your question correctly so [edit](https://stackoverflow.com/posts/64274376/edit) it: four spaces before every source code line. Read [*Modern C*](https://modernc.gforge.inria.fr/), the documentation of [GCC](http://gcc.gnu.org/), [this C reference](https://en.cppreference.com/w/c), the documentation of your editor (e.g. [VisualStudioCode](https://code.visualstudio.com/) or [GNU emacs](https://www.gnu.org/software/emacs/)), the documentation of your debugger (e.g. [GDB](https://www.gnu.org/software/gdb/)). On Linux your code compiles well – Basile Starynkevitch Oct 09 '20 at 05:30
  • 1
    Windows is different than "normal" systems, and it needs a special "main" function. And please use your favorite search engine to find clues. – Some programmer dude Oct 09 '20 at 05:36
  • 1
    most likely your telling the project definition that you are creating the wrong kind of project. – user3629249 Oct 09 '20 at 06:27

1 Answers1

0

The main issue is that "YOU DIDN'T save YOUR FILE", first save your cpp file then enter the command (g++ file.cpp) or run it. Usually, this error occurs when file was not saved.

so click anywhere on your file and press ctrl+s to save it again, NOW YOUR ERROR GOT FIXXED, ......................

  • related: [Why don't other programs see the changes I made to a file in VS Code until I save those changes?](/q/76984829/11107541) – starball Aug 26 '23 at 22:24