View Single Post
Old 10-06-2004, 06:06 PM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
does anyone know how to read in a steam of charactes, on after another, one at a time, and build a sentence out of them
Is this what you mean?
Code:
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
   string letters;
   string input;
   unsigned count(0);
   
   for(;;)
   {
      //Use getline so spaces and tabs are counted in.
      getline(cin, input, '\n');
      if(input[0] == '@') //@ terminates the input sequence.
         break;
      else
      {
         //Add only ONE single letter. Ignore the rest.
         letters+=input[0];
      }
   }
   cout<<letters<<endl;

   system("PAUSE");
   return 0;
}
If so, then try the rest of your assignment for yourself first. It's a nice excercise.
__________________
Valmont is offline   Reply With Quote