Advertisement
Guest User

What will C++ do now?

a guest
Jun 10th, 2015
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. void quiz(){
  2.     std::string s("1");
  3.    
  4.     {
  5.         std::istringstream exp(s);
  6.         exp.ignore();
  7.         std::cout << "1)" << "\t" << exp.eof() << "\t" << (exp.peek() == EOF) << std::endl;
  8.     }
  9.    
  10.     {
  11.         std::istringstream exp(s);
  12.         exp.ignore();
  13.         std::cout << "2)" << "\t" << (exp.peek() == EOF)  << "\t" << exp.eof() << std::endl;
  14.     }
  15.    
  16.     {
  17.         std::istringstream exp(s);
  18.         exp.ignore();
  19.         char c = '0';
  20.         std::cout << "3)" << "\t" << (c = exp.peek(), c);
  21.         std::cout << "\t" << (exp >> c, c) << std::endl;
  22.     }
  23.    
  24.     {
  25.         std::istringstream exp(s);
  26.         char c = '0';
  27.         std::cout << "4)" << "\t" << (exp >> c, c);
  28.         std::cout << "\t" << (exp >> c, c) << std::endl;
  29.     }
  30.    
  31.     {
  32.         std::istringstream exp(s);
  33.         exp.ignore();
  34.         char c = '0';
  35.         std::cout << "5)" << "\t" << (exp >> c, c);
  36.         std::cout << "\t" << (c = exp.peek(), c) << std::endl;
  37.     }
  38.    
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement