-2

I Cannot run my code due to this error in vs code. I cannot understand the error. I have attached the image link below.

https://i.stack.imgur.com/7FVJm.png

drescherjm
  • 10,365
  • 5
  • 44
  • 64
Muhsin
  • 27
  • 3
  • 6
    [Please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551). Copy and paste code as text into the question, also copy the error message as text. – Yksisarvinen Feb 02 '22 at 14:28
  • I can not search the web for your error, as it has been turned into a picture. – Drew Dormann Feb 02 '22 at 14:30
  • I think you have not saved your source file. As a result the file you are trying to compile is empty. Your linker fails to find `int main()` or `WinMain()` – drescherjm Feb 02 '22 at 14:32
  • why don't you search SO for this error, you are not the first, every few months we get a wave of this error, is it the start of a new school trimester – rioV8 Feb 02 '22 at 15:54
  • Anybody know how to apply a clue hammer to the vscode folks, to get them to, like *give the user a helpful warning* if they try to hit the Run button without saving? – Steve Summit Feb 02 '22 at 15:55
  • @Yksisarvinen In fairness, this is probably one of those cases where the image actually *is* useful. Several people got the clue from the OP's image that the code hadn't been saved, a detail which would likely not have showed up if the OP had just pasted the text of the error message. – Steve Summit Feb 02 '22 at 15:59
  • @SteveSummit I understood that they guessed file is not saved because of the error message (and mingw+VSCode default behaviours), not because of anything on the screen. I don't see any indication that file is modified on this screen. And, as it is, this question is not useful to anyone in the future - if I try to duckduckgo `Undefined reference to 'WinMain'`, I will not find this question or its answers. – Yksisarvinen Feb 03 '22 at 12:28
  • dup of: [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 27 '23 at 07:35

2 Answers2

1

Save your file by pressing ctrl+S and then run it again.

Farhan Ali
  • 116
  • 5
1

The thing happening here due to WinMain error is The compiler is not getting any instruction from where to start executing the code (This happens when we don't have a main() function in the program) As Your program already has the int main() function but it is clearly seen that you have not saved your file before Compiling so,

  1. You Should Save your file before running/compiling it byCtrl-S
  2. also, You can change the settings of the Code runner to Save on Run so you won't have to save your code again and again