Advertisement
Guest User

Untitled

a guest
Feb 5th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <sstream>
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. ifstream in("input.txt");
  10. string sdata; // Store string from file to display.
  11. string sname[3];
  12. string sgrade[4];
  13. int i = 0, j;
  14.  
  15. while (getline(in, sdata)) {
  16.  
  17. std::size_t found = sdata.find(": "); // Search for ": " string
  18. sname[i] = sdata.substr(found + 2);
  19. cout << sname[i];
  20.  
  21. for( j = 0 ; j < 4 ; j++ )
  22. {
  23. getline(in, sdata);
  24. std::size_t found = sdata.find(": "); // Search for ": " string
  25. sgrade[j] = sdata.substr(found + 2);
  26. cout << sgrade[j];
  27. }
  28.  
  29. getline(in, sdata);
  30. i++;
  31. }
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement