Simple question. In the program below, what if name of the company is larger than 20 characters. How can I do to printout the name up to 20 and ignore the rest. As is, if the name is more than 20 character will printout up to 20 and ends the program.
#include <iostream>
using namespace std;
struct pizza
{
char name[20;
float diameter;
double weight;
};
int main ()
{
pizza first =
{
"init",
0,
0
};
cout << "Company name";
cout << "\n";
cin >> first.name;
cout << "\n";
cout << "Enter the pizza diameter";
cout << "\n";
cin >> first.diameter;
cout << "\n";
cout << "Enter the pizza weight";
cout << "\n";
cin >> first.weight;
cout << "\n";
cout << "\n";
cout << "Your Pizza Company name is: "<< first.name << "\n";
cout << "The diameter of the pizza is: "<< first.diameter << " Inches"<< "\n";
cout << "The weight of the pizza is: "<< first.weight << " Pounds" << "\n";
cout << "\n";
return 0;
}