none
#include <iostream.h> & cout not recognized

    Question

  • // Hello2.cpp : Defines the entry point for the console application.

    //

    #include "stdafx.h"

    #include "iostream.h"

    int _main()

    {

    std::cout << "Hello World!" \n;

    return 0;

    }

     

     

    On build I get an error that reads, " 'iostream.h:' No such file or directory"

     

    This was suggested, but didn't work

     

    #include <iostream>
    
    using namespace std;
    
    void marker()
        {    // called by some constructor
        ios_base::Init unused_name;
        cout << "called fun" << endl;
        }
    I can get the program to work if I delete #include "iostream.h" and use printf instead of cout.
    Monday, November 05, 2007 4:04 PM

Answers

  • You should use #include <iostream> instead of #include <iostream.h> - the old version of iostreams, iostreams.h, was removed from the product.

     

    If you do this the first piece of code should work - if it doesn't please show us the error message. The second piece of code is unrelated to the first and is therefore probably failing for an unrelated reason.

    Monday, November 05, 2007 4:09 PM
    Moderator

All replies

  • You should use #include <iostream> instead of #include <iostream.h> - the old version of iostreams, iostreams.h, was removed from the product.

     

    If you do this the first piece of code should work - if it doesn't please show us the error message. The second piece of code is unrelated to the first and is therefore probably failing for an unrelated reason.

    Monday, November 05, 2007 4:09 PM
    Moderator
  •  scot.parker wrote:

    This was suggested, but didn't work

    #include <iostream>

    using namespace std;

    void marker()
    { // called by some constructor
    ios_base::Init unused_name;
    cout << "called fun" << endl;
    }
    I can get the program to work if I delete #include "iostream.h" and use printf instead of cout.


    In Addition to above Post What you mean that above code or
    #include <iostream> doesn't work . See in above example what is this marker() function this is not known to any of us .Anyway if you simply want to check whether #include <iostream> work or not you can do by simply writing few lines
    Code Block

    #include<iostream>

    using namespace std;
    int main()
    {
    cout<<"hello";
    return 0;
    }


    Thanx


    Monday, November 05, 2007 5:31 PM
  •  yes  ,i  have handled the question  as  you encountered . you  may   test your header  file using the short code:

    #include  "iostream"
    using  namespce std;
    viod main ()

                   cout<<" is  the  file  exsited ?"<<endl;
    }
      
      else   , if you included   a  other header  file ,you may   test the oder   of using  namespace code; 


    very glad  to  discuss   it!
    Wednesday, March 25, 2009 8:12 AM
  • Only use

    # include "iostream"
    • Proposed as answer by mehran_o0o Friday, May 20, 2011 9:53 PM
    • Unproposed as answer by mehran_o0o Friday, May 20, 2011 9:53 PM
    Monday, December 14, 2009 9:37 AM
  • first of all, you should rewrite your header like this:

    #include <iostream>

     

    and you need to make sure you declare what namespace you are using by writing "using namespace std" inside every function

     

    Your new program should look like this:

    #include "stdafx.h"

    #include <iostream>

    int _main()

    {

    using namespace std;

    std::cout << "Hello World!" \n;

    return 0;

    }

    Tuesday, April 12, 2011 4:13 AM
  • even #include <iostream> doesnt work... I can use it with notepad and build it with g++ on cmd... but not on vs 2008 or netbean or eclipse....
    Friday, May 20, 2011 9:51 PM
  • it still fails...
    Friday, May 20, 2011 9:54 PM
  • On 5/20/2011 5:51 PM, mehran_o0o wrote:

    even #include<iostream>  doesnt work... I can use it with notepad and build it with g++ on cmd... but not on vs 2008 or netbean or eclipse....

    Define "doesn't work". What code are you compiling, and what errors are you getting?


    Igor Tandetnik

    Friday, May 20, 2011 9:55 PM
  • mehran_o0o -

    You already posted a message about this in another thread:

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvc/thread/b2e8e2d5-7258-41b2-91d2-9d8c530cb874

    Don't multipost and don't tack your problems onto old and
    already "Answered" threads. Start *one* *new* thread for
    your problems.

    - Wayne
    Friday, May 20, 2011 10:35 PM
  • #include "stdafx.h"
    #include <iostream>
    using namespace std;

    int main()
    {
    cout << "Hello World!\n";

    return 0;

    }

    This is what worked for me.

    Sunday, December 23, 2012 9:39 PM