Public Group

# Simple C++ question

This topic is 3732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

What do I have to do to find errors? It says It couldn't compile a program because it had an error, but it wouldn;t indicate which line carried the error, and I find no go to line option to find it, I see nothing wrong with the program. I might as well copy paste it, it is the simplest program ever:
#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}

##### Share on other sites
What are you using to compile that? The error probably specifying something else and not the program.

##### Share on other sites
I see nothing wrong with it.What did the error say?

##### Share on other sites
Also what IDE are you using??

##### Share on other sites
Quote:
 Original post by sneaky_squirrel... it had an error, but it wouldn;t indicate which line carried the error, and I find no go to line option to find it

Sounds like a linker problem. The most common mistake would be to create a win32 project, instead of a console program (was my first mistake in C++ [smile]). Go to File->New->Project..., then locate "Win32 console application", fill in your project name and etc, click finish, then click "empty project" under "application settings" in the next dialog.

For further explanation, a win32 project looks for a WinMain entry, instead of a main.

##### Share on other sites
It compiles for me, but you generally don't put a space between a function name and the left parenthesis. And if you are using Microsoft Visual Studio, did you create an empty project?

##### Share on other sites
Quote:
 Original post by sneaky_squirrelWhat do I have to do to find errors?

Posting the error here might be a good start

##### Share on other sites
Some compilers require that you add parameters to the main function so replace this line

int main()

with

int main (int argc, char *argv[])

##### Share on other sites
Quote:
 Original post by Googol PL3XSome compilers require that you add parameters to the main function so replace this lineint main()with int main (int argc, char *argv[])

Which ones? Every compiler I've ever used seems to turn off parameter checking for main(). IIRC, the standard is quite lax about what is required here.

Quote:
 Original post by Googol PL3Xbut it wouldn;t indicate which line carried the error

If that is the case, _fastcall has the correct diagnosis. I'd agree that the most likely cause was creating a Win32 rather than console project.

Listen to Spoonbender. Post the error. It'll be solved in seconds.

##### Share on other sites
Some compilers also require you to put the full name of the header file. Instead of this: #include <iostream>
you put this: #include <iostream.h>

I recommend trying yo compile this way and then if it does not work try ading the args to the main function. Also if your IDE requires you to have any aditional code or format you should use it.
You can look for a simple helloworld in internet that has proven to work in your compiler via entering "Hello World in <your IDE name>"

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 12
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632991
• Total Posts
3009750
• ### Who's Online (See full list)

There are no registered users currently online

×