Home > Back-end >  Enter the company name just skip, why?
Enter the company name just skip, why?

Time:09-21

Include
# include
using namespace std;

Int main ()
{
String * p=new string;
String gongshiming;
* p=gongshiming;
String * q=new string;
String zhijing;
* q=zhijing;
String * m=new string;
String zhongliang;
* m=zhongliang;


Cout<& lt;" Enter the diameter of the pizza: \ n ";
Cin> Zhijing;
The delete q;
Cout<& lt;" Enter the name of the pizza company: \ n ";
Getline (cin, gongshiming);
The delete p;
Cout<& lt;" Input the weight of the pizza: \ n ";
Cin> Zhongliang;
The delete m;

CoutCoutCout
system("pause");
Return 0;
}

CodePudding user response:

To enter a pizza diameter when a carriage return is not block, directly by getline () function reads,
 cout & lt; <"Enter the diameter of the pizza: \ n"; 
Cin & gt;> Zhijing;
The rewind (stdin);//shielding carriage return -- -- -- -- -- -- -- -- -- -- -- -- -- --

VS2015 debugging environment of c + +

To block a carriage return, please see the reference
"C + + fflush () function and rewind () function,"
"C + + getchar () method of use"
Wish I could help you!

CodePudding user response:

reference 1st floor MianHou response:
input diameter pizza again when the carriage return is not block, directly by getline () function to read the
 cout & lt; <"Enter the diameter of the pizza: \ n"; 
Cin & gt;> Zhijing;
The rewind (stdin);//shielding carriage return -- -- -- -- -- -- -- -- -- -- -- -- -- --

VS2015 debugging environment of c + +

To block a carriage return, please see the reference
"C + + fflush () function and rewind () function,"
"C + + getchar () method of use"
Wish I could help you!

Thank you (* °?=3 °)

CodePudding user response:

refer to the second floor m0_46356449 response:
Quote: refer to 1st floor MianHou response:
input diameter pizza again when the carriage return is not blocking, directly by getline () function to read the
 cout & lt; <"Enter the diameter of the pizza: \ n"; 
Cin & gt;> Zhijing;
The rewind (stdin);//shielding carriage return -- -- -- -- -- -- -- -- -- -- -- -- -- --

VS2015 debugging environment of c + +

To block a carriage return, please see the reference
"C + + fflush () function and rewind () function,"
"C + + getchar () method of use"
Wish I could help you!

Thank you (* °? °)=3

You're welcome, it is good to help you!
  • Related