Search
 
SCRIPT & CODE EXAMPLE
 

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;
      }
  }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: remove element by index from vector c++ 
Cpp :: c++ system delay 
Cpp :: int_min in cpp 
Cpp :: c++ milliseconds 
Cpp :: unordered_map of pair and int 
Cpp :: como medir tiempo de ejecucion cpp 
Cpp :: c++ bold text 
Cpp :: sfml set font 
Cpp :: print hello world c++ 
Cpp :: initialize 2d vector as 0 
Cpp :: c++ celsius to fahrenheit 
Cpp :: uri online judge 3145 solution in c++ 
Cpp :: logisch und 
Cpp :: dev c++ tahe last word error 
Cpp :: create and write to a file c++19 
Cpp :: C++ add value to exception message 
Cpp :: certificate exe application 
Cpp :: how to change certain number from set c++ 
Cpp :: c++ display numbers as binary 
Cpp :: use regex replace in c++ 
Cpp :: number to binary string c++ 
Cpp :: Vector2 c++ 
Cpp :: using find in vector c++ 
Cpp :: cpp take lambda as parameter 
Cpp :: what is _asm in C++ 
Cpp :: c++ unordered_map check if key exists 
Cpp :: c++ check if string is empty 
Cpp :: how to check size of file in c++ 
Cpp :: c++ char to uppercase 
Cpp :: c++ call by value vs call by reference 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =