Home > Back-end > Why C loop input structure elements could go wrong?
Why C loop input structure elements could go wrong?
Time:09-20
Input: aa aa, left behind without input, and can't display properly, especially the cycle 3. What are the reasons? I know that is the reason of cin, but I don't understand why is cin, I change cin getline, and will have new problems,
Int main () { using namespace std; Inflatable guest= { "Glorious Gloria",//the name value 1.88,//volume value 29.99//price value };//guest is a structure variable of type inflatable //It 's an initialized to the indicated values Inflatable Pal= { "Audacious Arthur,"
3.12,32.99 };//Pal is a second variable of type inflatable //NOTE: some implementations require using //static inflatable guest=
Cout & lt; <"Expand your guest list with" & lt; Cout & lt; <"And" & lt; //Pal. The name is the name member of the Pal variable Cout & lt; <"You can have both for $"; Cout & lt; //cin. The get ();
//my structure array test Inflatable guest_array [3]. for (int i=0; i <3; I++) { Cout & lt; <"Both Please input the name:" & lt; //cin. Getline (guest_array [I]. Name, 20). Cin & gt;> Guest_array [I]. Name;