Please advise why I only get the first letter from my string entry.
Here is my output:
Enter name: test this
Enter number: 23
Name = t
Emp number = 23
************************
Here is my program:
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <iomanip.h>
#define FFLUSH while(cin.get() != '\n')
void getData(char[],int);
void main()
{
char name[20];
int emp;
getData(name,emp);
}
void getData(char name[],int emp)
{
cout << "Enter name: ";
cin.get(name, sizeof(name));
FFLUSH;
cout << "Enter number: ";
cin >> emp;
cout << "\nName = " << name << "\n"
<< "Emp number = " << emp << endl;
}
Here is my output:
Enter name: test this
Enter number: 23
Name = t
Emp number = 23
************************
Here is my program:
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <iomanip.h>
#define FFLUSH while(cin.get() != '\n')
void getData(char[],int);
void main()
{
char name[20];
int emp;
getData(name,emp);
}
void getData(char name[],int emp)
{
cout << "Enter name: ";
cin.get(name, sizeof(name));
FFLUSH;
cout << "Enter number: ";
cin >> emp;
cout << "\nName = " << name << "\n"
<< "Emp number = " << emp << endl;
}