Processing file streams in C + +

Source: Internet
Author: User

#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 + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.