Results 1 to 2 of 2

Thread: n00b win32 console question

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    n00b win32 console question

    I just started with C++ and started of with the hello world and just done some stuff with CIN but i wonder how to clear the screen after the user has typed something.. i want just a little program where he can add 2 number but when the user presses enter for the first number it should clear the screen and write it down for him (done it all except for the cls part) how to do this?




    and also how can i define a string
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    1. On Windows, you can use system("cls");:
    Code:
    #include <cstdlib>
    
    void somecode() {
        std::system("cls");
    }
    2. Like so:
    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main() {
        cout << "What's your name? " << flush;
    
        string nm;
        getline(cin, nm);
    
        cout << "\nHello " << nm << "!" << endl;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width