SHARE
TWEET

Untitled

a guest Jun 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top