-6

Whenever I try to run the code, it gives some error. How to resolve that?

enter image description here

EDIT After correcting ; it still shows this:

PS C:\Users\Dell\Desktop\C++> cd "c:\Users\Dell\Desktop\C++\" ; if ($?) { g++ test.cpp -o test } ; if ($?) { .\test }
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
rioV8
  • 24,506
  • 3
  • 32
  • 49
pi-π
  • 93
  • 5
  • Semi-colon...... – DeiDei May 16 '20 at 15:59
  • 2
    Please don't *ever* post images of code. Post code as *text*. Same goes for error messages. – Jesper Juhl May 16 '20 at 16:00
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/q/12573816/5910058) – Jesper Juhl May 16 '20 at 16:08
  • 1
    The error is exactly this one from the previous comment link: [https://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16/5260237#5260237](https://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16/5260237#5260237) – drescherjm May 16 '20 at 16:19
  • @drescherjm I suggest closing as a duplicate of that. – Jesper Juhl May 16 '20 at 16:41
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – drescherjm May 16 '20 at 16:45
  • make sure you save your file before compiling it – Alan Birtles May 16 '20 at 16:57
  • My IDE doesn't accept images. My IDE can't extract the text from the image. No code posted as text == no help. – Thomas Matthews May 16 '20 at 19:09

2 Answers2

2

I guess you configured project as some type of "Windows application" instead of "console application"

In programming there are those pieces called "functions" and classical c++ application is started by calling function called "main", but widows application use "WinMain" instead so it tries to find "WinMain" which does not exists, try to create new project and make sure it's some kind of "consol application" not "windows application" since even if you change main to WinMain it still might cause more problems in future.

Mwarw
  • 56
  • 3
0

Put Semicolon ";" at the end of line 5 Please read about c++ more :)

RahulAN
  • 97
  • 1
  • 1
  • 7