Maruf_Hasan

delete num

Jun 23rd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. void deletenum:: delete_number(string nam)
  2. {
  3. fstream fin,fout;
  4. fin.open("file1.csv",ios::in);
  5. fout.open("file2.csv",ios::out | ios::app);
  6. vector<string>row;
  7. string line,word,temp;
  8. int cnt=0;
  9. while(getline(fin,line))
  10. {
  11. row.clear();
  12. // getline(fin,line);
  13. stringstream s(line);
  14. while(getline(s,word,','))
  15. {
  16. row.push_back(word);
  17. }
  18. if(nam==row[0]){
  19. continue;
  20. }
  21. else
  22. {
  23. fout<<row[0]<<","<<row[1]<<endl;
  24. }
  25. }
  26. fin.close();
  27. fout.close();
  28. remove("file1.csv");
  29. rename("file2.csv","file1.csv");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment