Thread: What in the world?

  1. #1
    Novice C++ Programmer
    Join Date
    Nov 2003

    What in the world?

    This is an incredibly simple problem (I assume) because it has to do with a very simple program. In fact, I've written much more advanced things than this such as a calculator, database, and a guessing game. For some reason I decided to take a pretty long break from C++ (As you can see my last post was quite a while ago). Well now I'm back for good. No more of that break stuff Unfortunately I lost almost all my work due to my over-excitement about a disk reformat. So I installed the GCC compiler, added the the bin directory to my path variable, created an ever-so-simple program:

    #include <iostream>
    using namespace std;
    int main()
    	char test;
    	cout << "Okay, this is a test!\n";
    	cin >> test;
    	return 0;
    Fired up the compiler, only to get this error:
    test.cpp: In function 'int main()':
    test.cpp:6: no match for 'std:stream& >> const char[22]' operator
    This is despicable... I must be out of my mind...

  2. #2
    Registered User
    Join Date
    Nov 2001
    One solution is add std infront of the cout and cin. Another solution is to add std::cout and using std::cin.


  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well this works
    cout << "Okay, this is a test!\n";

    But this generates your error message
    cout >> "Okay, this is a test!\n";

    Posting the code you tried to compile helps...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Ontario, Canada
    What command were you using to compile your code?
    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

  5. #5
    Novice C++ Programmer
    Join Date
    Nov 2003
    It's fixed now. It was an editor problem. The editor wrote a blank .cpp file and then saved my code elsewhere. Thanks for the help though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The 7 New Wonders of the World
    By Mario F. in forum A Brief History of
    Replies: 36
    Last Post: 12-08-2006, 01:55 PM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  4. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM
  5. No More Technology After World War Three
    By Unregistered in forum A Brief History of
    Replies: 16
    Last Post: 09-20-2001, 07:02 PM