G++ --> iostream.h: No such file or directory
Hello guys,
I recently switched to ubuntu, so kinda new to it. I installed g++ by Code:
sudo apt-get install build-essential Code:
#include<iostream.h> Code:
garment.cpp:1: fatal error: iostream.h: No such file or directory Please shed some light on it LQ members.. And btw, this is Ubuntu 10.10. Thanks! |
Hi -
Please try this program: Code:
#include <iostream> Quote:
Code:
#include<iostream> Note, too, that "conio" is for DOS systems. It's totally obsolete in contemporary systems. If you need terminal control, consider a library like ncurses. If you'd like a GUI, consider a toolkit like GTK+ or Qt. And if you just need quick'n'dirty keyboard input, use "cin" and "cout". 'Hope that helps .. PSM |
Quote:
What could be wrong w/ my program? I've already tried removing .h from iostream.h and adding using namespace std; to no avail... |
Thanks again for your help. Its late night here and have school tomorrow.
Will do the revisions as you said and post the outcome.. Quote:
Quote:
|
Quote:
|
Ok here's the revised code, I ran it in Turbo C++ (Windows), it ran successfully.
But in linux, issuing: Code:
g++ garment2.cpp -o garment2exe Code:
garment2.cpp:53: error: ‘::main’ must return ‘int’ Code:
#include<iostream> |
You have written void main, it means it returns nothing, at the same time you have put, return 0, you need to remove either of the two. i.e.
make it int main or remove return 0. |
Quote:
"int main" is the proper way and adheres to the standard. And it's not like it's much harder to type. |
Hah! What a silly error i made... :P
Anyways, when i tried compiling that w/ void main changed to int main, following error pops-up: Code:
/tmp/ccpdzlRX.o: In function `garments::input()': |
Quote:
It's just reminding you that gets() is dangerous because if the user types in a line longer than the buffer tht you provide it, it could overwrite parts of memory that it shouldn't, and lead to bad things. |
Oh I just ran it and its working nicely w/ the only exception that its not accepting value for Garment's fabric.. It just skips it.. Is it because of gets? But gcode, gtype also uses gets to take input and these are working fine. . .
Thanks anyways.. :) |
Quote:
Use std::getline() to read in a string. |
Even if you choose to use STL string objects, I just wanted to say this:
There's another alternative to gets(), called fgets(). It's better because it takes an additional parameter that specifies the size of the buffer. If the line is longer than the buffer, then fgets() will return as much as the buffer can hold (note that the rest of the line is not lost forever, subsequent calls to fgets() will keep returning the remaining parts of the long line until you get to the end). But it also takes a stream parameter which gets() doesn't have. For reading keyboard input, just use "stdin" (it's predefined in cstdio). |
Quote:
However, during compilation, there were some warnings: Code:
garment2.cpp: In member function ‘void garments::input()’: Here's the final code: Code:
#include<iostream> |
Quote:
|
All times are GMT -5. The time now is 11:44 AM. |