Need HELP! C++, displaying NAME already and to get input form user, like registration

*/ am new to programming, mark me where am doing wrong, its to ask user to input FIRST NAME, SECOND NAME, DOB, HOURLY WAGES*/

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char a[40], b{50], c[60], d[70];
cout << "A new job applicant`s First name" << endl;
cin >> a;
cout << "A new job appilcant`s Last name" << endl;
cin >> b;
cout << "A new job appilcant`s date of birth" << endl;
cin >> c;
cout << "A new job appilcant`s hourly wage" << endl;
cin >> d;
cout << "FIRST NAME " << a << endl;
cout << "LAST NAME " << b << endl;
cout << "DATE OR BIRTH" << c << endl;
cout << "HOURLY WAGES " << d << endl;
_getch();
return 0;
}
Last edited on
b{50]
should be
b[50]
(as I'm sure that your compiler would tell you).

Please put code fragments in code tags. ( <> in the formatting menu.)
Also never use a function that doesn't limit the number of characters it will try to retrieve (such as the extraction operator) when using C-strings. First prefer C++ strings over C-strings. If you must use C-strings then either use getline(), which limits the number of characters retrieved or use the setw() manipulator to limit the number of characters it will try to retrieve: std::cin >> std::setw(40) >> a;

By the way, even in small examples like this, you should be using meaningful variable names and it is best to avoid antiquated constructs such as "#include <conio.h>", let this anachronism retire into history. Instead use modern constructs such as std::cin.get() instead.

Topic archived. No new replies allowed.