3. Assume the array name is defined as follows:
char name[25];
A) Using a stream manipulator, write a cin statement that will read a string into name, but will read no more characters than name can hold.
b) Using the getline function, write a cin statement that will read a string into name but that will read no more characters than name can hold.
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
char name[25];
getline(cin, name);
cout << name << endl;
system("pause");
return 0;
}
The error is in the way I used getline, what did I do wrong ?