Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Use cin get() to read a string based on char array

#include <iostream>    int main()  {      char buffer[80];      std::cout << "Enter the string: ";      std::cin.get(buffer, 79);       // get up to 79 or newline      std::cout << "Here's the buffer:  " << buffer << std::endl;      return 0;  } Enter the string: string Here's the buffer: string