Getting a error because of #include <iostream>

I'm using CodeBlocks and I get a error saying that there is a mistake because of #include <iostream> here is the code.
1
2
3
4
5
6
7
8
9
10
11
12
//This is a string lol
#include <iostream>
#include <string>
using namespace std;

int main(){

string mystring = "My String";
cout << mysting;
return 0;

}
Can you copy in the error it returns? It might help to know what is says exactly.
1
2
 string mystring = "My String";
cout << mysting;


That's your problem: 'mysting' is not a declared variable, so the cout object can't do anything with it.
I downloaded the pdf file from http://www.cplusplus.com/doc/tutorial/ Im just doing everything the book is telling me. And I did change that but still get the error.
Last edited on
Please post the error then.
For no reason I tried #include "iostream.h" and it worked...
I tried #include "iostream.h" and it worked...


This is because you are using a C++ compiler a decade old (or more), and as such it does not understand C++ - only some pre-standard approximation of very old C++.

You can get a new, real C++ compiler for free. Please do.
Topic archived. No new replies allowed.