Maruf_Hasan

revised remove phone

Jun 25th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. void Admin::Remove_phone()
  2. {
  3. int choice;
  4. while(true)
  5. {
  6. cout<<"Enter Which Type of Phone U want to Delete from the List"<<endl;
  7. cout<<"1.Featured phone"<<endl;
  8. cout<<"2.Midrange phone"<<endl;
  9. cout<<"3.Flagship phone"<<endl;
  10. cout<<"4.Apple Phone"<<endl;
  11. cout<<"0.Exit"<<endl;
  12. cin>>choice;
  13. if(choice==0)
  14. return;
  15. fstream fin,fout;
  16. fin.open("Mobilelist.csv",ios::in);
  17. fout.open("New1.csv",ios::out | ios::app);
  18. vector<string>row;
  19. string line,word,temp;
  20. int cnt=0;
  21. cout<<"Enter the Name of Phone U want to Remove"<<endl;
  22. string name;
  23. cin>>name;
  24. while(getline(fin,line))
  25. {
  26. row.clear();
  27. // getline(fin,line);
  28. stringstream s(line);
  29. while(getline(s,word,','))
  30. {
  31. row.push_back(word);
  32. }
  33. if(name==row[3]){
  34. continue;
  35. }
  36. else
  37. {
  38. for(int i=0;i<row.size();i++)
  39. {
  40. fout<<row[i]<<",";
  41. }
  42. fout<<endl;
  43. }
  44. }
  45. fin.close();
  46. fout.close();
  47. remove("Mobilelist.csv");
  48. rename("New1.csv","Mobilelist.csv");
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment