0
Guys what's wrong in my code ? i tried to use cin.ignore but it's not working
2 ответов
0
I made this solution that works...
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;
int main()
{
string lname ,fullname, middle;
char fname[20], address[20];
int cpnum, byear, age;
cout << "Input Last Name: ";
cin >> lname;
getchar();
cout << "Input First Name: ";
cin.getline(fname, 20);
cout << "Input Middle Initial: ";
cin >> middle;
getchar();
cout << "Input Address: ";
cin.getline(address, 20);
cout << "Input Contact Number: ";
cin >> cpnum;
cout << "Input Birth Year: ";
cin >> byear;
fullname = fname+middle+lname;
age = 2021-byear;
cout << endl << endl;
cout << "Full name: " << fullname << endl;
cout << "Address: " << address << endl;
cout << "Contact Number: " << cpnum << endl;
cout << "Birth Year: " << byear << endl;
cout << "Age: " << age << endl;
return 0;
}