Results 1 to 2 of 2

Thread: How to get user input (sentences) ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    101

    How to get user input (sentences) ?

    Good day !

    As far as i know, usually we will use "cin" to get the user input and store it inside a variable right ?

    But now if i wish to get a sentence from a user and store it inside an array, how can I accomplish that ?

    I have tried the following code :

    cout << "Please enter your sentence : ";
    cin >> NormalData;
    cout << NormalData;

    where the NormalData is the array of characters.

    Let say I input "I am idiot" when it asked for input, what I got for the output is just "I" ....

    I think there's a function where I can rip the whole sentence , but I forgot what's that already.

    Help !

    Thanks a lot !

    SonicWave

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    string str;
    getline(str, cin);
    ...IIRC.
    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