i am just start learning string
and this program allow user to enter id and will show what id user enter
but if user enter "0001"
the program just show "1"
so how can i solve this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string id[2];
for (int a=0;a<1;a++)
{
cout<<"enter your id :";
cin>>id[a];
cout<<id[a]<<endl;
}
system("pause");
return 0;
}
Modify line 7 for 2 values for a. Also, id[] is an array of integers so its content will be of...integers, e.g: 1, -3 etc. Try to use for id[] string not int.