Help Needed

LLeweLLyn Reese llewelly@lifesupport.shutdown.com
Tue Mar 18 01:51:00 GMT 2003


Karthik Narayanan <rkarthik@cs.ucf.edu> writes:

> Hi,
>    Here is the attachment of the file that i created according to you
> instructions.

Thank you - but you didn't post the error messages.
[snip]
> On Sun, 2003-03-16 at 16:29, LLeweLLyn Reese wrote:
> > "R.Karthik Narayanan" <rkarthik@cs.ucf.edu> writes:
> > 
> > > Hi,
> > >    I am R.Karthik Narayanan, I am student at UCF. I have been trying to do
> > > programming in lunix using GCC. I find that my C programs work without any
> > > errors. But the problems seems to happend when i do GCC for C++ programs. It
> > > fails to find the file iostream.h.
> > 
> > iostream.h is not part of ISO C++. The name was changed to <iostream>
> >     (no suffix) during the standarization process which was completed
> >     in 1998. (Although the iostream.h => iostream change was final
> >     long before most of the other changes.)
> > 
> > Since you don't know about <iostream>, I'm going to assume you don't
> >     know about the std namespace. During the standarization process,
> >     all standard C++ library names, including cout, endl, string, etc,
> >     were moved into the std namespace. Here is an example:
> > 
> > #include<iostream>
> > #include<ostream>
> > 
> > using std::cout;
> > using std::endl;
> > 
> > int main()
> > {
> >     cout << "Hello world" << endl;
> > }
> > 
> > > But, there is no error nad the program
> > > compiles.
> > 
> > I think there is some confusion. If iostream is required, but not
> >     found, the program will not compile. You must copy and paste the
> >     exact error messages you get, and the code that reproduces them
> >     (or a simplified version thereof). If you don't do that, people
> >     can only guess at your problem, and are less able to help you.
> > 
> > > But when i try to execute it using ./name of compiled file, there is
> > > no reponse, the program doesn't run. Can u please guide me as to how solve this
> > > problem.
> > [snip]
> 
> 
> #include<iostream>
> #include<ostream>
> using std::cout;
> int main()
> {
> 	cout<<"HelloWorld!";

cout is a buffered stream. This means it saves the output in a buffer,
    until a long block of optimal size is obtained. The buffer isn't
    written to output until it is full, or gets flushed. I don't
    believe the standard requires the buffer to flushed when the
    program exits. So if you do not use << flush, or << endl here, you
    may see no output.

> 	return 0;
> }











More information about the Gcc-help mailing list