Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. void insertAtLine(int lineNumber,string line)
  2. {
  3. ofstream myfile("C:\Users\test\Music\myfile.txt");
  4.  
  5. int counter=0;
  6. if(myfile.is_open())
  7. {
  8. string str;
  9. do{
  10. getline(cin, str);
  11. if(counter == lineNumber)
  12. {
  13. myfile<<line<< endl;
  14. }
  15. counter++;
  16.  
  17. }while(str!="");
  18. myfile.close();
  19. }
  20. else cerr<<"Unable to open file";
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement