Issue with C++

Morning, i have a problem with C++, i finished my algorithm and the following massage appeared:

undefined reference to 'WinMain'
[Error]id returned 1 exit status

And this is my algorithm:(Its very simple, in deed)

#include <iostream>
#include <locale>
using namespace std;
int dias, anos;
intmain ()

{
setlocale (LC_ALL, "ptb");
cout << "Informe a quantidade de dias que você já viveu \n";
cin >> dias;
anos = dias/365;
cout << "Você já viveu " << anos << "anos.";

}
WinMain is the entry point for a Windows GUI based program, not a console program.

Are you using some version of Visual Studio? If you are you need to create your project as a Console App, not a Windows Desktop Application.

A tutorial for VS2017 or 2019 to create a console app.
https://www.learncpp.com/cpp-tutorial/writing-your-first-program/
I believe that is a MinGW/variant message.

The solution is similar, though. Make sure your IDE (Code::Blocks?) has your project listed as a (Native) Windows Console Application. Otherwise it will add -mwindows to the compiler’s command invocation and get you that error.

Good luck!
or put a space after int.
you can get that same error on Cygwin if you left main out or had a typo.
LOL, I assumed that “intmain” was a typo...

Cygwin uses a MinGW variant.
Last edited on
No code tags, so I kinda missed the typo....mea culpa, my fault, and all that jazz.
Thanks you all, but it was vey simple, i puted a space between "int" and "main" and worked, like jonnin said.
Topic archived. No new replies allowed.