Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void insertAtLine(int lineNumber,string line)
- {
- ofstream myfile("C:\Users\test\Music\myfile.txt");
- int counter=0;
- if(myfile.is_open())
- {
- string str;
- do{
- getline(cin, str);
- if(counter == lineNumber)
- {
- myfile<<line<< endl;
- }
- counter++;
- }while(str!="");
- myfile.close();
- }
- else cerr<<"Unable to open file";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement