Cant get past 1st simple code.

+2 Andrew Walker · February 8, 2016
im new to C++ im trying to run the sample code in code blocks and i get an error.

#include <iostream>

using namespace std;

int main()
    cout << "Hello world!" << endl;
    return 0;

||=== Build: Debug in Learning_this (compiler: GNU GCC Compiler) ===|
/Users/s/Desktop/learnings/Learning_this/main.cpp|1|error: iostream: No such file or directory|
/Users/s/Desktop/learnings/Learning_this/main.cpp||In function 'int main()':|
/Users/s/Desktop/learnings/Learning_this/main.cpp|7|error: 'cout' was not declared in this scope|
/Users/s/Desktop/learnings/Learning_this/main.cpp|7|error: 'endl' was not declared in this scope|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Post a Reply


Oldest  Newest  Rating
0 Dean Li · March 14, 2016
Check the name of the file, sometimes you can select the C file type and you may see it as a cpp file. When that happens you'll get the error message you just posted.
0 Adam Tindall · February 12, 2016
Hello, you may find this useful if you get a snag in these tutorials:
0 Moayid Al Subhi · February 11, 2016
You could try Code Blocks 
+1 Lachezar Peshterliev · February 10, 2016
Download Dev C++ it is very simple compiler. :)  I think that it is better for newbies. 
+1 anthony scafe · February 10, 2016
Try this instead of what Boston put
using namespace std;

int main()
       cout << "Hello World!";
       return 0;
+1 Eric Persson · February 9, 2016
If you are running Avast on your computer, or any other anti virus software for that matter, that might block some of Code::Blocks stuff.

Try disabling these in you anti virus software: 

  • - enable deepscreen

  • - enable hardened mode 

  • - enable reputation services

psAlso just to be certain that it works, you might have to delete your project and restart code::blocks!ds
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator