Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  47] [ 0]  / answers: 1 / hits: 216627  / 2 Years ago, thu, march 17, 2022, 8:56:35

I do not want to discuss about C++ or any programming language!I just want to know what am i doing wrong with linux ubuntu about compiling helloworld.cpp!



I am learning C++ so my steps are:



open hello.cpp in vim and write this



#include <iostream.h>
int main()
{
cout << "Hello World!
";`
return 0;
}


So, after that i tried in the terminal this



g++ hello.cpp


AND the output is



hello.cpp:1:22: fatal error: iostream.h: No such file or directory
compilation terminated.


What do you suggest? Any useful step by step guide for me?Thanks!


More From » compiling

 Answers
2

You should use #include <iostream>, not iostream.h; the .h form is very old and deprecated since years.



You can read more than you probably want to know on the .h vs non-.h forms here:
http://members.gamedev.net/sicrane/articles/iostream.html



(Plus, you should write std::cout or have a line using namespace std; otherwise your next error will be about the compiler not finding a definition for cout.)


[#38801] Saturday, March 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cretanol

Total Points: 320
Total Questions: 99
Total Answers: 115

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
cretanol questions
Fri, Dec 2, 22, 13:30, 1 Year ago
Thu, Dec 8, 22, 03:00, 1 Year ago
Mon, Aug 1, 22, 03:21, 2 Years ago
Fri, Sep 24, 21, 16:28, 3 Years ago
Sun, Apr 24, 22, 06:37, 2 Years ago
;