Re: newbie needs with user input into strings
On Oct 17, 5:41 pm, 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
// there is no need to be including arguments u don't need.
// i just compiled this in .NET and it works fine
//when u running the code make sure u not in debug mode so it dosen't
blow by.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout <<"Enter your name _\b";
cin >> name;
cout <<endl;
cout << name<< endl;
return 0;
}
|