Help -- what is wrong with this code?

#include<iostream>
using namespace std;
int main()
{ <------------- The error keeps popping up on this and the int main()

int hours;
int minutes;
int seconds;
int total_seconds;

cout << "Please enter # of hours:";
cin >> hours;

cout << "Please enter # of minutes:";
cin >> minutes;

cout << "Please enter # of seconds:";
cin >> seconds;

total_seconds = hours*3600+minutes*60+seconds;
cout<<"The total seconds are:"<< total_seconds <<endl;
return 0;
}
What's the error
Compiled fine as is on G++ 4.5.2 Cygwin and MinGW Windows 7 x64.

There are no errors in the code that can be seen.
If you're using Visual Studio, and it's asking for "stdafx.h"/precompiled headers, then try out the steps I listed here:

http://www.cplusplus.com/forum/beginner/49254/
The first error I get when saving it is there are multiple definitions of '_main'

It saves, then I run it and I receive an error that the program file specified does not exist.

I'm a student just learning this, so I'm working with the C++ software when I compile and run it.

It looks okay to me too, so I'm stumped.
Last edited on
Here's what I get when I build my project:

**** Build of configuration Debug for project Hello World ****


make all

Building target: Hello World.exe

Invoking: Cygwin C++ Linker

g++ -o "Hello World.exe" ./Hello\ World.o ./Hey.o ./Seconds.o

cygwin warning:

MS-DOS style path detected: C:\Users\Chris\workspace\Hello World\Debug

Preferred POSIX equivalent is: /cygdrive/c/Users/Chris/workspace/Hello World/Debug

CYGWIN environment variable option "nodosfilewarning" turns off this warning.

Consult the user's guide for more details about POSIX paths:

http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

./Seconds.o: In function `main':

/cygdrive/c/Users/Chris/workspace/Hello World/Debug/../Seconds.cpp:5: multiple definition of `_main'

./Hey.o:/cygdrive/c/Users/Chris/workspace/Hello World/Debug/../Hey.cpp:13: first defined here

collect2: ld returned 1 exit status

make: *** [Hello World.exe] Error 1


**** Build Finished ****



What are all these extra files? Hey.o and Seconds.o?

Try this as the command:
g++ -o HelloWorld Hello\ World.o
You can only have one int main() in any program.
using that command it runs now, but the screen is blank. I would think I should see something on the screen since I'm asking for input...
When I run the command that wolfgang gave me, my program doesn't display any errors, but I also do not see the prompts. What could be the problem?
Maybe and ONLY maybe there is some issues in
make
inside Window$? AFAIK it was originally meant for Linux users?

Try to compile your program without make..
Topic archived. No new replies allowed.