Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. static void listStudents(){
  2. cout << endl << "List students" << endl<< endl;
  3. ifstream textfile;
  4. string line;
  5. string unused = "";
  6. textfile.open("students.txt");
  7. if(textfile.is_open()){
  8. int count = 0;
  9. for(int i = 0 , j = 0; !textfile.eof(); i++){
  10. if(i == j){
  11. count++;
  12. textfile >> line;
  13. cout << count << ": " << line;
  14. textfile >> line;
  15. cout << " " << line << endl;
  16. j+=11;
  17. }else{
  18. textfile >> unused;
  19. unused = "";
  20. }
  21. }
  22. }else{
  23. cout << "You don't have any students!" << endl;
  24. }
  25. textfile.close();
  26. cout << endl << endl;
  27. main();
  28. }
  29.  
  30. !textfile.eof()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement