Here is my code
#include <iostream>
using namespace std;
int main() {
int age;
cin >> age;
cout << "Age is " << age << endl;
return 0;
}
Whenever I run the program, I get errors saying that 'cout', 'endl' and 'cin'are not declared in this scope. I looked up this problem online and I made sure I had the "using namespace std;". Another post mentioned this was a bug and said that to fix this bug I would change
""C_Cpp.intelliSenseEngine": "Default" to "C_Cpp.intelliSenseEngine": "Tag Parser"."
I did this and it still doesn't work. Anyone have any ideas?
Edit: Here is the Error Code:
PS C:\School\C++\C++ VSD> cd "c:\School\C++\C++ VSD\" ; if ($?) { g++ test.cpp -o test } ; if ($?) { .\test }
test.cpp:3:2: error: invalid preprocessing directive #using
#using namespace std;
^~~~~
test.cpp: In function 'int main()':
test.cpp:7:5: error: 'cin' was not declared in this scope
cin >> age;
^~~
test.cpp:7:5: note: suggested alternative:
In file included from test.cpp:1:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:60:18: note: 'std::cin'
extern istream cin; /// Linked to standard input
^~~
test.cpp:8:5: error: 'cout' was not declared in this scope
cout << "Age is " << age << endl;
^~~~
test.cpp:8:5: note: suggested alternative:
In file included from test.cpp:1:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:61:18: note: 'std::cout'
extern ostream cout; /// Linked to standard output
^~~~
test.cpp:8:33: error: 'endl' was not declared in this scope
cout << "Age is " << age << endl;
^~~~
test.cpp:8:33: note: suggested alternative:
In file included from C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/iostream:39,
from test.cpp:1:
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ostream:590:5: note: 'std::endl'
endl(basic_ostream<_CharT, _Traits>& __os)