Beginner question here

im sure this is a noob question here, so sorry about that. and i have searched the web and tried figuring out this out but i cant seem to find anything although im sure that is just a simple mistake or something.

But anyways im trying to make my IDE run the statment below.

int x;
x = 5;
cout << x;

but my results are always:

error: "x" does not name a type
error: 'cout' does not name a type

is there something i need to add? is it just invalid? or what can i do to fix this. thanx
The snippet looks fine. Could you post the entire code inside [code] tags?
sure,

1
2
3
4
5
int main()

int x;
x = 5;
cout << x;
Im also using code blocks, and this is under "Console Application" projects, if that helps
That doesn't look like the whole code, but supposing it is you are missing braces around the contents of main() and you need to #include <iostream>
Topic archived. No new replies allowed.