Y'ello Paul!
11 Apr 97, All had to endure Paul C Purgett's ramblings (shown below).
PCP> I recently purchased Visual C++ 1.0 (Windows). I was wondering
PCP> how to enter, say, a sentence, and have the program recall the
PCP> sentence.
Here's something to chew on:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Simple I/O by Craig A McKay (c) 1997 McMoose Systems
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include
const int MAX_BUF = 256 ;
int main(void)
{
char inbuf[MAX_BUF] ; // Buffer space for sentence
cout << "Enter sentence: " << flush ; // Ask for input
cin.get(inbuf, MAX_BUF, '\n') ; // Get up to MAX_BUF chars
// terminated by newline
cout << "You typed: " << inbuf << endl << flush ; // Echo text
return(1) ;
}
I suppose, thought, if we're going to call it "C++", we'd better make it
Object Oriented and have at least one class...
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
EasyIO by Craig A McKay (c) 1997 McMoose Systems
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include
#include
const int MAX_BUF = 256 ;
class EasyIO
{
private:
char the_sentence[MAX_BUF] ; // Buffer space for sentence
public:
EasyIO() { strcpy(the_sentence, "") ; }
int getSentence()
{
// Ask for input
cout << "Enter sentence: " << flush ;
// Get up to MAX_BUF chars terminated by newline
cin.get(the_sentence, MAX_BUF, '\n') ;
return ( strlen(the_sentence) ) ;
}
void putSentence()
{
cout << "You typed: " << the_sentence <<
endl << flush ;
}
} ;
int main(void)
{
EasyIO eio ;
if (eio.getSentence() > 0) eio.putSentence() ;
return(1) ;
}
There ya go! Mind you, I've just read your message again... and noticed the
VisualC++ part, which means you don't want to know any of my rabid ramblings.
I
used VC++ 1.0 at work, it's an older version, but perfectly useable. You
probably want to take your sentence from a Textbox or something like that do
you? If you can cut'n'paste you could try the above provided there's a
console
or something similar. Hmm. Well, just tryin' to help. :)
Fido = 2:259/33
--Craigzilla++ Internet = McMoose@sol.co.uk
WWW = http://www.taynet.co.uk/users/mcmoose/
--- GEcho 1.00
---------------
* Origin: The Kilted Bun, Letham Angus -- hame o' the McMoose (2:259/33)
|