Thread: Invalid operand error with cout???

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    167

    Invalid operand error with cout???

    This is error:

    "AsciiTable.cpp": AsciiTable.cpp invalid operands of types `char' and ` at line 21

    Here's the code

    Code:
     
    #include <iostream>
    
    using std::cout;
    using std::endl;
    
    #include <iomanip>
    
    using std::ios;
    using std::setiosflags;
    using std::hex;
    using std::dec;
    using std::oct;
    
    #include "AsciiTable.h"
    
    void AsciiTable::Print() const
    {
        for( int i = 35; i < 128; i++ ){
    
             cout.put(i);
             cout<< '\t' << i << hex << i < '\t' << oct << i << endl;
        }
    }
    What am I doing wrong?
    silk.odyssey

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    i < '\t'
    You need <<.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    LOL thanks for pointing that out. You have good eyes. Why didn't the stupid compiler tell me that?
    silk.odyssey

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    It did. You were trying to use comparison, and that's what it told you.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Infinite Loop when entering invalid input
    By acwheat in forum C Programming
    Replies: 5
    Last Post: 04-18-2006, 04:17 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. changing cout output
    By Yohumbus in forum C++ Programming
    Replies: 1
    Last Post: 10-23-2002, 04:09 AM
  4. Redirecting cout stream
    By Arrow Mk84 in forum C++ Programming
    Replies: 1
    Last Post: 10-08-2002, 04:17 PM
  5. automatic terminate after 5 invalid entries
    By ZeeeD in forum C Programming
    Replies: 1
    Last Post: 09-09-2001, 05:01 AM