Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual c++ can't open include file 'iostream'

Tags:

c++

I am new to c++. I just started! I tried a code on visual c++ 2010 Express version but i got the following code error message.

 ------ Build started: Project: abc, Configuration: Debug Win32 ------   ugo.cpp c:\users\castle\documents\visual studio 2010\projects\abc\abc\ugo.cpp(3): fatal error C1083: Cannot open include file: 'iostream': No such file or directory ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

This is the code

// first.cpp -- displays a message   #include <iostream>   // a PREPROCESSOR directive  int main(void)        // function header {             // start of a function body   using namespace std;   cout << "Come up and C++ me sometime.\n";  // message   // start a new line   cout << "Here is the total: 1000.00\n";   cout << "Here we go!\n";   return 0; } 
like image 917
jamesbond Avatar asked Jul 29 '12 23:07

jamesbond


People also ask

What does #include iostream do in C++?

So, #include is a preprocessor directive that tells the preprocessor to include header files in the program. < > indicate the start and end of the file name to be included. iostream is a header file that contains functions for input/output operations ( cin and cout ).

Why is iostream not working in code blocks?

you have missing iostream. h file in you mingw directory folder placed inside codeblocks/devc++. what you have to do is just download the file from link given below and replace with your previous mingw folder in codeblocks/devc++.

Is iostream a header file in C?

C++ input/output streams are primarily defined by iostream , a header file that is part of the C++ standard library (the name stands for Input/Output Stream). In C++ and its predecessor, the C programming language, there is no special syntax for streaming data input or output.


2 Answers

Replace

#include <iostream.h> 

with

using namespace std;  #include <iostream> 
like image 138
Michael Haephrati Avatar answered Oct 07 '22 20:10

Michael Haephrati


Some things that you should check:

  • Check the include folder in your version of VS (in "C:\Program Files\Microsoft Visual Studio xx.x\VC\include" check for the file which you are including, iostream, make sure it's there).

  • Check your projects Include Directories in <Project Name> > Properties > Configuration Properties > VC++ Directories > Include Directories - (it should look like this: $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;)

  • Make sure that you selected the correct project for this code (File > New > Project > Visual C++ > Win32 Console Application)

  • Make sure that you don't have <iostream.h> anywhere in your code files, VS doesn't support that (in the same project, check your other code files, .cpp and .h files for <iostream.h> and remove it).

  • Make sure that you don't have more than one main() function in your project code files (in the same project, check your other code files, .cpp and .h files for the main() function and remove it or replace it with another name).

Some things you could try building with:

  • Exclude using namespace std; from your main() function and put it after the include directive.
  • Use std::cout without using namespace std;.
like image 32
Secko Avatar answered Oct 07 '22 21:10

Secko