Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. void second()
  2. {
  3.     ifstream file("Example.txt");
  4.  
  5.     string name;
  6.     string iq;
  7.  
  8.     char c;
  9.     string line;
  10.  
  11.     while (getline(file, line))
  12.     {
  13.         for (int i = 0; i < line.length(); i++)
  14.         {
  15.             c = line[i];
  16.             if (c >= '0' && c <= '9')
  17.             {
  18.                  iq += c;
  19.             }
  20.             else
  21.             {
  22.                 name += c;
  23.             }
  24.         }
  25.  
  26.         cout << "Name : " << name << " IQ : " << iq << endl;
  27.         name = " ";
  28.         iq = " ";
  29.     }
  30.  
  31.     file.close();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement