Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void existnum:: modifyname(string nam)
- {
- fstream fin,fout;
- fin.open("file1.csv",ios::in);
- fout.open("file2.csv",ios::out | ios::app);
- vector<string>row;
- string line,word,temp;
- int cnt=0;
- while(getline(fin,line))
- {
- row.clear();
- // getline(fin,line);
- stringstream s(line);
- while(getline(s,word,','))
- {
- row.push_back(word);
- }
- if(nam==row[0]){
- cnt=1;
- cout<<"Enter the Modified Name"<<endl;
- string newname;
- cin>>newname;
- fout<<newname<<","<<row[1]<<endl;
- //break;9
- }
- else
- {
- fout<<row[0]<<","<<row[1]<<endl;
- }
- }
- fin.close();
- fout.close();
- remove("file1.csv");
- rename("file2.csv","file1.csv");
- }
Advertisement
Add Comment
Please, Sign In to add comment