Reads multiple lines, terminates on '$' character - C++ File Stream

C++ examples for File Stream:cin

Description

Reads multiple lines, terminates on '$' character

Demo Code

#include <iostream>
using namespace std;
const int MAX = 2000;                //max characters in string
char str[MAX];                       //string variable str
int main()//from www.ja  v a2 s.c  om
{
   cout << "\nEnter a string:\n";
   cin.get(str, MAX, '$');           //terminate with $
   cout << "You entered:\n" << str << endl;
   return 0;
}

Result


Related Tutorials