C ++-delete the last line of code of the text (C ++)

Source: Internet
Author: User

Delete the last line of code of the text (C ++)

 

 

Read textEach line (), Stored inArray vector In the output, only the last line is output less.

 

Code:

 

/* * main.cpp * *  Created on: 2014.06.08 *      Author: Spike *//*vs 2012*/#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      using namespace std;int main(){vector
      
        tmp_files;ifstream infile( w.txt );if (!infile) {cout << fail! << endl;return 0;}string lineContent;while ( getline( infile, lineContent, '' ) ){tmp_files.push_back(lineContent + );}infile.close();ofstream outfile( w2.txt,ios::out );vector
       
        ::iterator siter = tmp_files.begin();copy( tmp_files.begin(), tmp_files.end()-1, ostream_iterator
        
         (outfile) );cout << ok! << endl;outfile.close();return 0;}
        
       
      
     
    
   
  
 

Output:

 

 

Original metadata (metadata txt): FemaleSisterGirlWomanOld womanoutput metadata (w2.txt): FemaleSisterGirlWoman


 

 

 

Related Article

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.