Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
demo.cpp:5:1: error: expected unqualified-id before '{' token


What I have tried:

#include <iostream>
using namespace std;

int main()
{
    std::cout << "Hello World!";
    return 0;
}
Posted
Updated 19-May-21 8:33am
Comments
Richard MacCutchan 19-May-21 12:51pm    
Nothing wrong with that code, it compiles and runs fine.
merano99 19-May-21 14:30pm    
Maybe some invisible characters in line 4. Copy the text into a simple editor (notepad or something similar) and save it again.

1 solution

There's nothing wrong with that code.

Unless you're trying to compile C++ code using a compiler that only supports C, or you've used the wrong command line arguments for your compiler, whatever that is.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900