#include <bits/stdc++.h>using namespacestd;structbian{intnum; stringname;} b[ -];intMain () {ifstream fp ("Bianhao.txt"); if(!Fp.is_open ()) {cout<<"Error Opening file"; Exit (1); } for(intI=0;i< A; i++) FP>>b[i].num>>B[i].name; for(intI=0;i< A; i++) cout<<b[i].num<<" "<<b[i].name<<Endl; Bian a[15427]; Fp.close (); Fp.open ("Source.txt"); if(!Fp.is_open ()) {cout<<"Error Opening file"; Exit (1); } for(intI=0;i<15427; i++) {FP>>A[i].name; for(intj=0;j< -; j + +) if(A[i].name==b[j].name) {a[i].num=b[j].num; Break;} } cout<<a[15400].name<<" "<<a[15400].num; Fp.close (); Ofstream FP2; Fp2.open ("Getinzu.txt"); for(intI=0;i<15427; i++) {FP2<<A[i].num; //fp2<< ""; //fp2<<a[i].name<<endl;fp2<<Endl; }}View Code
In C + + batch processing files is very convenient, can achieve accurate batch modification, replacement and other functions.
The corresponding substitutions are placed in "Bianhao.txt" and the files that need to be batched are placed in "Source.txt".
Once the data in the file is extracted, it can be processed and then exported to a file.
Processing file streams in C + +