I am trying to set up a visual studio code for programming in C ++. I have already installed the C / C ++ and C / C ++ Intellisense extensions
Below is my code:
#include<iostream>
using namespace std;
int main()
{
cout<< "hello" ;
}
The error I get is identifier cout is undefined, and when I write it as std::cout, I get an error namespace std has no member cout. Below is my file task.json:
{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"tasks": [
{
"taskName": "Makefile",
"isBuildCommand": true,
"showOutput": "always",
"args": ["all"],
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
How to fix it?
source
share