Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

modify file CPP

#include <iostream>
#include <string.h>
#include <fstream>

using namespace std;

int main()
{
  ofstream outFile("temp.txt");
  ifstream readFile("test.txt");

  string readLine;
  string search;
  string firstName;
  string lastName;

  cout<<"Enter The Id :: ";
  cin>>search;

  while(getline(readFile,readLine))
  {
      if(readLine == search)
      {
          outFile<<readLine;
          outFile<<endl;

          cout<<"Enter New First Name :: ";
          cin>>firstName;
          cout<<"Enter New Last Name :: ";
          cin>>lastName;

          outFile<<firstName<<endl;
          outFile<<lastName<<endl;
      }else{
          outFile<<readLine<<endl;
      }
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #modify #file #CPP
ADD COMMENT
Topic
Name
1+6 =