Error: expected unqualified-id before '{' token

Hi, I am using an online compiler, and I have an error on line 10 of my code, apparently. The error message reads this:

main.cpp:10:1: error: expected unqualified-id before '{' token

This is the code:

  #include <iostream>
#include <string>

int main();

using namespace std;

//Last Edited: 09:28 17/06/2013


    string startUp = "Starting Program... !$%^&%5&^%£4%&7^*&(^&(%$^*";
    cout << startUp << endl;
    cout << "Testing Protocol: Captial - A a AA aa Aa aA" << endl;
    cout << "Test Succesful. Scanning for files..." << endl;
    cout << "Virus Found - U://ICT//" << endl;
    cout << "Terminating program ..." << endl;
    cout << "**&^&%$^$%&%^*$£%^*£***(*£&%!" << endl;

    return 0;

What is it, and what is wrong with the brace?

Move using namespace std; to line 3.
What pebble said, then remove the semi-colon from the end of line 4.
Hi everybody, my problem is fixed, but as you can see, the sleep function is there with no executor. Can anybody here tell me how to activate/execute the sleep function? (Forgive me, I am using very simple terminology because I am a beginner, and I am not yet used to all of the correct phrases used in C++ programing.)
I don't know what you mean by "no executor". You're certainly calling the sleep function several times in the code you've posted. What makes you think you aren't?
I haven't used a '#include' or 'int()' function/piece of code to activate the sleep function. How do I get the sleep function to work?
I haven't used a '#include'

Is your code compiling? If not, then you need to #include the correct header file.

If it is compiling, then you can assume a function declaration is in there somewhere. It must have been in one of the files that's included by <iostream> or <string>. It would be good practice to explicitly include the correct header file for sleep as well, but it's not strictly necessary if something is else is already including it for you.

or 'int()' function/piece of code to activate the sleep function.

I don't know what you mean by this. You already are calling the sleep function. It's right there in your code.

How do I get the sleep function to work?

What makes you think it isn't working? What results are you seeing that make you think that? You've not been clear about what problem you're seeing.
Last edited on
It isn't working because #include <iostream> does not include sleep. What I'm asking in short is, 'What Does?'.
So, you mean it's not compiling? It would help if you explained your problems more clearly. It always helps to post the actual text of the errors you're getting, too.

What platform are you on? I think on Linux, it's in <unistd.h>, but I could be misremembering. I also think it sleeps for the specified number of seconds - do you really want to be sleeping for 1000 seconds?

If you're on Windows, the function is Sleep, and it the argument is in milliseconds. According to MSDN, it's in different header files for different Windows versions, so you'll have to have a look at the documentation yourself to see which one is right for your version of Windows.
Sorry! I am using an online compiler, that I think is based upon Windows. In this case, 1000 refers to 10 seconds, does it not. In the case that it is based on Linux, that's where I am a beginner, as I have no experience with Linux whatsoever. You could say that I am a 'Die Hard Windows Fan', but that's besides the point.

I'm sorry, I am a beginner, but does anybody here understand what I mean?

Thanks anyway, everybody!
The Windows library function is Sleep. It takes a number of milliseconds as an argument.

The Linux library function is sleep. It takes a number of seconds as an argument.

You need to first find out what platform your online compiler uses, and then use the correct function name and arguments.
Ah! Now my problem is much closer to being solved! Thank you for your help, MikeyBoy!
You're welcome :)
Topic archived. No new replies allowed.