Code::Blocks/ Dev-c++: error: iostream: No such file or directory

戏子无情 提交于 2019-12-06 07:40:28

Is this in a file like "program.c" or "program.cpp"? If it's a .c file, then your compiler may be interpreting it as C, and not C++. This could easily cause such an error. It's possible to "force" the compiler to treat either such extension as the other, but by default, .c files are for C, and .cpp files are compiled as C++.

It's either this, or somehow your default "include" directories for the standard library are not set up right, but I don't know how you'd fix that, as that'd be compiler/environment dependent.

I also had that problem when trying to run my first program in Code::Blocks. My file was saved with '.c' extension as 'test.c' and when I saved it as 'test.cpp', it worked fine.

It is also worth mentioning that I had to restart Code::Blocks before new 'test.cpp' file was compiled successfully.

While saving your source code before compiling just save the name with extension ".cpp". You wont get the error..

Javed Iqbal

Use <iostream> instead of <iostream.h> and add std:: before cout, cin etc

Use std::cout << "Welcome";
instead of cout << "Welcome";

Save the file with .cpp extension

I got the same problem.

Change #include < iostream.h > to #incude < iostream >

Consequently, in your program, change every keyword related to iostream, such as cin cout and endl to std::cout, std::cin and std::endl

That'll do the trick

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++.

http://www.4shared.com/rar/owp-D0Km/mingw.html

Hughie

I found the problem was cause by having a previous version of cgg and cpp in a Perl installation. The Perl structure did not have the correct library files. When I added C:\MinGW\bin and C:\MinGW\MSYS\1.0\bin to the path, I added them at the end so it picked up the Perl install first. I moved the path variable entries to the beginning and reopened my cmd window and it now works because it finds the MinGW version first.

Type path to see your path environment varialble. Mine now looks like:

C:\MinGW>path
PATH=C:\MinGW\bin;C:\MinGW\MSYS\1.0\bin;C:\Perl\site\bin;C:\Perl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\BluetoothSoftware\;

Apparently you want to create a c++ file. But you allowed your computer to auto provide the file extension C/C++. When it does that it automatically provides a file extension of ".c". Which is not corect. You want ".cpp".

Solution: Rename your file with a ".cpp" extension, or else explicitly state your extension when saving new files by putting ".cpp" (without quotes of course) after your intended file name; i.e. specify your file extension.

user3023906

you written your program in C++ code use c code then your program run correctly

in first line use it

#include <Io stream.h>
main ()
{

in ending line use it

system (pause");

You are trying to make a C game right? If you are your code is C++ not C. So if you are trying to make a C game than you should change your code. This might help.

Just put "Using namespace std;" before main() to define the scope of identifiers you are using. This will handle your problem easily.

IwishIknewMore

Try including iostream.h instead of iostream.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!