Thread: I cant do it but its in the tutorial

  1. #16
    Registered User
    Join Date
    Jan 2005
    >> Dont really need the <<endl; thing

    It will flush the buffer, which should be done before the cin.get() call, but you never know. That code should work on that compiler, so we are all just guessing. The return 0, on the other hand, shouldn't make any difference.

  2. #17
    Registered User
    Join Date
    Dec 2005
    SERIOUSLY: AFTER you see the 13 outputted on the screen, do you type 13 and then press enter??! cuz if you don't, THAT'S the problem--you should!!! lol

    the problem is simple, and it doesn't have anything to do with the code but with the level of comprehension of the code form the "coder's" part.
    the cout<<"13"; line is clearly the source ...but what none thought to ask clearly out of the nice young lad here is whether he actually inputs anything after he sees "13" outputted on the screen, when running the program. i think he doesn't. he gets discuraged by the 13 already there, thinks there's something wrong with the code, and doesn't input the age...thus, nothing happens.

  3. #18
    Registered User
    Join Date
    Jan 2006
    enumclaw wa

    WHOA thnx

    Yeah I wan't typing in 13 and pressing enter I just did it. AND IT WORKED!!! Thnx for all the help guys and I will continue replying. Oh yeah and I had a typo it is and not 4.9.92 srry
    Last edited by milesmiles; 01-31-2006 at 05:48 PM.

  4. #19
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    >> Dont really need the <<endl; thing

    It will flush the buffer, which should be done before the cin.get() call, but you never know.
    cin is linked with cout (I forget the exact term), so that whenever you call cin, cout is flushed.

    Why do you think this works?
    #include <iostream>
    int main(void) {
        std::cout << "Enter a number: ";
        int n;
        std::cin >> n;
        return 0;
    You would think cout wouldn't be flushed, and it wouldn't print the prompt. But it does.

    If you want to flush a stream without printing a '\n', use flush:
    cout << "Reading from file" << flush;

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #20
    Me pwn you.
    Join Date
    Feb 2006
    At my computer or in my bed.
    If Anyone cares, this, I think, is better than system("Pause");


    That way it does't display the anoying "press any key to continue. . ." message. I know that isn't what you guys are talking about, but hey!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My new website
    By joeprogrammer in forum A Brief History of
    Replies: 19
    Last Post: 03-17-2006, 07:38 PM
  2. Cprog tutorial: Design Patterns
    By maes in forum C++ Programming
    Replies: 7
    Last Post: 10-11-2004, 01:41 AM
  3. Tutorial review
    By Prelude in forum A Brief History of
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  4. Problem with tutorial (Vector class)
    By OdyTHeBear in forum C++ Programming
    Replies: 4
    Last Post: 12-18-2002, 02:49 PM
  5. My DirectInput tutorial....
    By jdinger in forum A Brief History of
    Replies: 1
    Last Post: 06-18-2002, 11:32 PM