topical media & game development

talk show tell print

professional-program-14-Get-Get.c

? / professional-program-14-Get-Get.c


  include <iostream>
  include <string>
  
  using namespace std;
  
  string readName(istream& inStream);
  
  int main()
  {
    cout << "Reading a name from cin. You can usually close cin with Control-D (Control-Z in Windows): ";
    string theName = readName(cin);
  
    cout << "The name is " << theName << endl;
  }
  
  string readName(istream& inStream)
  {
    string name;
    char next;
    while (inStream.get(next)) {
      name += next;
    }
  
    return name;
  }
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.