Re: [Dev-C++] Insight Debugger questions
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Verne H. B. <ve...@sy...> - 2005-03-22 15:38:54
|
Nope, Alfred, it doesn't do the job as about all I get out of same is =
one letter or word at the most. Here's the code to a complete little =
program and though I see what I type it only prints out the first word. =
We're missing something here somewhere. Oh well more reading is due I =
guess. Thanks for this.
Verne
***************************************
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
string story;
cin >> story;
cout << story<< "\n";
system("PAUSE");
return EXIT_SUCCESS;
}
*************************************
When it runs type 'Plumbing is my business.' and it will only print =
out Plumbing.
There's different methods. If you're using cout then that implies =
C++. Use the string class instead of the char keyword. The string =
class with cin would already separate the input at the newline =
character.
Then it would be (provided sentences where input with the Enter key):
string line;
cin >> line;
cout << line;
For char's it's a little harder as you have to capture the tokens. =
Look up String Manipulation on the Microsoft Run-Time Library Reference =
Site. strtok is an example. It also depends on whether you are =
terminating sentences on newlines, ". ", or whatever your token is. As =
an example, "This is a test. This is another." would have a token ". " =
for the first sentence, and a terminating token of ".\n" You'd have to =
separate the two, and would have to handle the time when the user =
forgets the period!
There's also formatted input, which I haven't used in so long that =
I've forgotten how to use it! See Standard C I/O, and C++ I/O from the =
C/C++ Reference site. Check out my links page section on Programming at =
http://www.geocities.com/alreaud/Links_Page.htm. Just use the left =
frame, click on Computers and Internet, then click on Programming.
Hope this helps!=20
"Verne H. Bohlender" <ve...@sy...> wrote:
Nice Alfred, mine lived well into his 95th year but the last few he =
was dozy. I don't want that and just too much to learn. Something I'm =
stuck on right now is if I ask someone a question and want to be able to =
cout the entire line, just how do I use char for that. =20
I know that char name [85]; lets one enter a good long name but I =
want a means of picking up a sentence. I'm sure it's in the book some =
place but not entirely sure where to look or what to look for. Any help =
on this simple thing.
Verne
I'm impressed Verne!<snip>=20
Alfred P. Reaud
|