cant find my error

The resut will be "user name is:-858993460" dont know where i did wrong thx a lot for helping : >
[code]
#include<iostream>;
using namespace std;
int main()
{
int name;
cout << "USER NAME:";
cin >> name;
cout << "user name is:" << name << endl;





system("pause");


return 0;
}
Last edited on
int name;

and you enter aaronkong here

a string in a name will give stupid values.....

use string instead
Change the int to a string.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<iostream>
#include<string> //<--- added #include<string>
using namespace std;
int main()
{
string name; //<--- changed int to string
cout << "USER NAME:";
cin >> name;
cout << "user name is:" << name << endl;


system("pause");


return 0;
}
ok thx ill try it now
Topic archived. No new replies allowed.