stupid question

This is a discussion on stupid question within the C++ Programming forums, part of the General Programming Boards category; hi i am having trouble compiling my program i think the problem is probably very simple but i cant figure ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    stupid question

    hi i am having trouble compiling my program i think the problem is probably very simple but i cant figure it out
    Code:
    #include<iostream>
    
    main(){
    	char c[]="hi\n";
    	stdout << c;
    
    	return 0;
    }
    i am using microsoft visual c++ here is what the error message is C:\Programs\calculator\test.cpp(5) : error C2296: '<<' : illegal, left operand has type 'struct _iobuf *'
    C:\Programs\calculator\test.cpp(5) : error C2297: '<<' : illegal, right operand has type 'char [22]'

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    stdout is not declared anywhere. In C++ cout is the standard/default stream object used to display to the standard output unit (that is to display to the screen). Given your use of the iostream without the .h you will need to indicate namespace somehow. Adding the line


    using namespace std;

    between the first and third line of your program is probably the simplest, though not necessarily the best, approach to indicating namespace for now.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    i think maybe u meant to type
    Code:
    std::cout
    When no one helps you out. Call google();

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    44
    is there anyway to declare an output or input stream yourself or do you have to use the iostream include?

  5. #5
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Quote Originally Posted by kwm32
    is there anyway to declare an output or input stream yourself or do you have to use the iostream include?
    You can't declare an ostream or an istream because they'll keep all constructors away from you. You can create new stream objects with your own implimentations if you absolutely needed/wanted to.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Question Probably
    By Kyrin in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 12:51 AM
  2. Replies: 7
    Last Post: 11-03-2005, 11:17 PM
  3. Stupid Question
    By digdug4life in forum C++ Programming
    Replies: 22
    Last Post: 05-17-2005, 11:43 AM
  4. stupid, stupid question
    By xelitex in forum C++ Programming
    Replies: 5
    Last Post: 12-22-2004, 07:22 PM
  5. Stupid question: What does Debugger do?
    By napkin111 in forum C++ Programming
    Replies: 6
    Last Post: 05-02-2002, 10:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21