Thread: Using Cin.get()
View Single Post
Old Nov 25th, 2004, 1:31 PM   #1
mswift
Newbie
 
Join Date: Nov 2004
Posts: 5
Rep Power: 0 mswift is on a distinguished road
Okay I am learning C++ using the book: Teach Yourself C++ third Edition.

I am trying to write a simple program, that asks the user for some text then, out puts that text as well as the count of characters used.

My program is using cin.get()
I need to use this so I can see the result of my program and make sure it is working correctly, but I can't seem to get cin.get() working. here is the code:

/*
A C++ program that uses I/O to prompt user for a striong and then display its length
*/

#include <iostream>
#include <string> // library that allows the use of cin.get(); (stops the program) I think
using namespace std;

int main()
{
char i;
double d;


cout << "Please enter some text.";

cin >> i;
cout << i;



cin.get();

return 0;

}
mswift is offline   Reply With Quote