Check out example codes for "input a string in c++". It will help you in understanding the concepts better.

Code Example 1

// C++ program to understand the use of getline() function 
  
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    string S, T; 
  
    getline(cin, S); 
  
    stringstream X(S); 
  
    while (getline(X, T, ' ')) { 
        cout << T << endl; 
    } 
  
    return 0; 
}

Code Example 2

string fullName;
cout << "Type your full name: ";
getline (cin, fullName);
cout << "Your name is: " << fullName;

Code Example 3

// CPP program to convert string 
// to char array 
#include <iostream> 
#include <string.h> 
  
using namespace std; 
  
// driver code 
int main() 
{ 
    // assigning value to string s 
    string s("geeksforgeeks"); 
    // declaring character array : p 
    char p[s.length()]; 
  
    int i; 
    for (i = 0; i < sizeof(p); i++) { 
        p[i] = s[i]; 
        cout << p[i]; 
    } 
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com