main.cpp:7: error: 'cout' was not declared in this scope
main.cpp:7: error: 'endl' was not declared in this scope
I tried google but all I found were people who forgot to include the namespace declaration or the header file. I really don't see what's wrong. I tried reinstalling the mingw compiler and added the path to the iostream file do my environmental variables. I restarted the computer, but it still doesn't work. A few weeks ago, the codes were compiling fine, but all of a sudden I started getting these errors, which makes me think the problem's not in the code itself, but in something I did to my computer. Does anyone have any idea of what it might be?
The code is perfectly fine.
What version of MinGW are you using?
and added the path to the iostream file do my environmental variables.
That sounds fishy - it's not necessary and perhaps even contra-productive.
Something about your install is probably broken. Remove MinGW tracelessly, remove the entry from your PATH variable and download and install the latest release here: http://tdm-gcc.tdragon.net/
Oh, I just found out what happened. I uninstalled the old version of MinGW and restarted the computer to install the new version, like you told me to. I decided to check that I had really removed it completely by trying to compile my c++ program. Surprisingly, the program compiled just fine! I thought: how could it be, since I had no compiler. However, I searched for leftover mingw files and found an old DevC++ directory with mingw files in it. It turns out that I uninstalled DevC++ but the files were not completely removed. And, since it comes with a compiler, I ended up with two versions of mingw. When I uninstalled the most recent one, everything went back to normal. Perhaps the compiler was getting confused with the ambiguity of having iostream files in two accessible directories.
Thank you very much for your help. Everything's working fine now.
im really stuck on this same issue but ive checked the compiler..i'm really new to programing like day 3 new and am sure it's something simple but if i could get some help on this i could move past this and move on in my learning.
here's the code:
#include <iostream>
int main() {
cout << "\n i am a programer.";
cout << "\n this is great code.";
cout << "\n do you like my style. im done. \n";
return 0;
}
(this is example code from a book just so y'all did'nt think i was a loser)