View Single Post
  #1 (permalink)  
Old July 21st, 2011, 07:46 PM
gimmybob2 gimmybob2 is offline
Registered User
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default cin.getline issues

Hello-
I am new to C++ and was am working my way through a book and doing the exercises. One of these exercises was to write a program that will get the user to enter a string and then print it back out. I decided to use the cin.getline iostream function to accomplish this. Here is the pertinent code:
Code:
 char buffer[30];
		cin.getline(buffer, 30, '\n');
		for(int i = 0; i < 30; i++)
			cout << buffer[i];
However, when I compile and run this program, a blank terminal simply flashes on and then disappears into cybernetic oblivion and I never get a chance to enter input. What did I do wrong?
Reply With Quote