Re: newbie needs with user input into strings
On Oct 18, 12:41 am, rob <rob1...@gmail.com> wrote:
> hello all. im a newbie in C++ and programing in general. what i am
> having problem with is taking user input, putting it into a string and
> then displaying that string again. i am using the dev C++ compiler.
> here is the code
>
> #include <iostream>
> #include <stdlib.h>
> #include <string>
>
> using namespace std;
>
> int main(int argc, char *argv[])
> {
>
> string name;
>
> cout << "Enter name: ";
> cin >> name;
> cout << endl << "Your name is " << name << endl;
>
> cin.get();
>
> return 0;
>
> }
>
> it will let me input what ever i want but nothing happens when i hit
> enter, the window just stays blank until i hit enter again then the
> window closes.
>
> thanks for any
Something related to implementation, There was sth related to conio
header and pause() function, try them and see what happens, your code
looks fine at first sight.
cin.get() just extracts the newline in the stream, and you are not
using that for anything why did you put that there?
HTH, Regards
|