View Single Post
  #2 (permalink)  
Old September 19th, 2011, 04:22 PM
MtD MtD is offline
Registered User
 
Join Date: Sep 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Since you're using C++, try the user-friendly C++ std::string, instead of not-so-user-friendly C-style char array.
So, essentially:
Code:
#include <iostream>
#include <string>
 
int main()
{
  std::string UserEnteredString;
  std::cin >> UserEnteredString;
  std::cout << UserEnteredString << '\n';
 
}
Incidentally, you don't have to print out your C-style char array "buffer" character-by-character, you can simply stream the entire thing via cout: http://www.cplusplus.com/reference/i...tream/getline/
Reply With Quote