if your not newb you can help me

This is a discussion on if your not newb you can help me within the C++ Programming forums, part of the General Programming Boards category; i a newb and i need some help that is confusing me. see this code? #include <iostream.h> int main() { ...

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    Exclamation if your not newb you can help me

    i a newb and i need some help that is confusing me. see this code?

    #include <iostream.h>
    int main()
    {
    int thisisanumber;
    cout<<"Please enter a number:";
    cin>>thisisanumber;
    cout<<"You entered: "<<thisisanumber;
    return 0;
    }


    thats from a tutorial from this site. once i eneter a number and press eneter to confirm the window closes. I bielive tha happens because of this line cin>>thisisanumber; what do I press to go to the line cout<<"You entered: "<<thisisanumber;
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    206
    #include <iostream.h>
    int main()
    {
    int thisisanumber;
    cout<<"Please enter a number:";
    cin>>thisisanumber;
    cout<<"You entered: "<<thisisanumber;
    cin>>thisisanumber;
    return 0;
    }

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    how was that helpful you just reposted the code i gave you!
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  4. #4
    Unregistered
    Guest

    Arrow I know

    Your code is fine. What is happening is your program is closing before you have time to see the results... Try putting
    Code:
    getchar();
    just before return 0; and #include <stdio.h>, so your code would be:
    Code:
    #include <iostream.h> 
    int main() 
    { 
    int thisisanumber; 
    cout<<"Please enter a number:"; 
    cin>>thisisanumber; 
    cout<<"You entered: "<<thisisanumber; 
    getchar();
    return 0; 
    }

  5. #5
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    >>how was that helpful you just reposted the code i gave you!

    I believe if you look you'll see an additional line in the code Denthor2000 gave back:

    cin>>thisisanumber;

    at the end before the return statement. This will cause your app to pause and wait for input before closing you window, thus giving you time to read. Its one af 100 ways of doing it, but probably the easiest in this situation as it doesnt require any additional headers.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  6. #6
    Unregistered
    Guest

    Oops

    Sorry, that would be:
    Code:
    #include <stdio.h>       // I forgot to mention this, :D
    #include <iostream.h> 
    int main() 
    { 
    int thisisanumber; 
    cout<<"Please enter a number:"; 
    cin>>thisisanumber; 
    cout<<"You entered: "<<thisisanumber; 
    return 0; 
    }

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    206
    Originally posted by Klinerr1
    how was that helpful you just reposted the code i gave you!
    actually, look again. try compiling it before you post. If you looked closely you would see the difference, look:

    you posted:
    Code:
    #include <iostream.h> 
    int main() 
    { 
    int thisisanumber; 
    cout<<"Please enter a number:"; 
    cin>>thisisanumber; 
    cout<<"You entered: "<<thisisanumber; 
    return 0; 
    }
    i posted:
    Code:
    #include <iostream.h> 
    int main() 
    { 
    int thisisanumber; 
    cout<<"Please enter a number:"; 
    cin>>thisisanumber; 
    cout<<"You entered: "<<thisisanumber; 
    cin>>thisisanumber; 
    return 0; 
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newb Question Character Counting
    By Wilder in forum C Programming
    Replies: 13
    Last Post: 06-23-2008, 12:37 AM
  2. Dogpile the newb!
    By lindy in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 05-23-2008, 09:17 AM
  3. Total newb directx invisable geometry question
    By -pete- in forum Game Programming
    Replies: 5
    Last Post: 08-13-2006, 02:45 PM
  4. Newb C++ Programmer
    By Philandrew in forum C++ Programming
    Replies: 8
    Last Post: 10-19-2004, 09:44 PM
  5. Newb With Small Pointer Issue
    By G-Prime in forum C Programming
    Replies: 7
    Last Post: 09-06-2004, 05:09 PM

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