-3

I am using Windows 8.1 and Dev C++ and I have the following code:

#include<iostream.h>
main()
{
    cout<<"welcome to devc++";
    system("pause");    
}

The syntax is correct, but I get an error that says:

[Error] iostream.h: No such file or directory

I have tried to change to location of this .cpp folder, watched video tutorials, but I could not point out why I am getting this error and how to remove it.

Tas
  • 7,023
  • 3
  • 36
  • 51
String Ana
  • 21
  • 1
  • 1
  • 7
  • 2
    Use only `iostream` and it should be `int main()`. – abhishek_naik Jun 29 '16 at 04:54
  • I think you're using Orwell Dev-C++. It comes in two flavours, with and without compiler suite. If you're using the latter, you've to manually set up the compiler. If you're unsure, you should use the package that comes with the compiler. All this if you face the error even after switching to ``. – legends2k Jun 29 '16 at 04:58
  • You may want to read a modern book on C++. iostream.h went obsolete some 18 years ago. – n. m. could be an AI Jun 29 '16 at 05:05

3 Answers3

2

You need to use #include<iostream> instead of #include<iostream.h>. The later one has been deprecated now; which is why you face the error. More details here.

Besides, main() being a function, should have a return type. So, you should write int main() and not just main().

Community
  • 1
  • 1
abhishek_naik
  • 1,287
  • 2
  • 15
  • 27
1

Just do,

#include <iostream> 

instead of

#include <iostream.h>

because, as C++ progressed from specific implementation to standard one,.h were deprecated from he library.

msc
  • 33,420
  • 29
  • 119
  • 214
0

In addition to changing to

#include <iostream> 

You can also add

using namespace std;

before main if you want to use cout without having to use std::cout.