Use cin.getline to read a char array based string : Char Array « Data Type « C++






Use cin.getline to read a char array based string

  
#include <iostream>
using namespace std;
int main()
{
  
 char name[25];
 cout << "Please enter your name \n";
 cin.getline(name,25);
 cout << "Hello " << name << endl;
 return 0;
}
  
    
  








Related examples in the same category

1.use char array as string
2.use getline to read char array based string
3.Char array and char pointer
4.Use new operator to allocate memory for char array