Apr 26, 2015 at 12:11pm UTC
Write your question here.
new i have another question
if i change number 3 [ for(int x=0; x< 3); x++) ] with a variable , the programe won't work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include <iostream>
#include <string>
using namespace std;
struct Wgwagner
{
string fullname;
unsigned int ZimNum;
string Stdgg;
};
int main()
{
int n; // if i use this 2.lines ,the programe won't work
cin>> n; //
Wgwagner personel[100];
for (int x = 0; x < n; x++) // i replaced a constane with a variable n
{
cout << "Enter name #" << x + 1 << " : " ;
getline(cin, personel[x].fullname);
cout << "Enter ZimNum " << x + 1 << " : " ;
cin >> personel[x].ZimNum;
cin.ignore(10, '\n' );
cout << "Enter Stdgg #" << x + 1 << " : " ;
getline(cin, personel[x].Stdgg);
cout << endl;
}
cout << endl << endl;
for (int x = 0; x < n; x++) // // i replaced a constane with a variable n
{
cout << personel[x].fullname << " " << personel[x].ZimNum << " " << personel[x].Stdgg << endl;
}
return 0;
}
Last edited on Apr 26, 2015 at 12:14pm UTC
Apr 26, 2015 at 12:21pm UTC
question : when the programe runs , it's writes "Enter ZimNum " and "Enter Stdgg #" at the sametime . it must wait until i typ a number or something else
Apr 26, 2015 at 12:29pm UTC
Put cin.ignore();
under/after cin >> n;
This will fix the problem:)
Last edited on Apr 26, 2015 at 12:33pm UTC
Apr 26, 2015 at 12:37pm UTC
thank you very much catctus :-)