Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to combine multiple text files into one ?

How to combine multiple text files into one ?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snailflying
    wrote on last edited by
    #1

    Now i have lots of text files in a folder,i want to combine them into one large file,but the problem is that it is must be order the formation rule. for instance:(the txt file order) the first text file list item"1c.txt,2c.txt,......... the second text file list item"1e.txt,2e.txt,........ now the combine file order must be "1c.txt,1e.txt,2c.txt,2e.txt........." and so on! Waiting for ur help! Thx advance!;P

    Don't try it, just do it! *Archibald*rever dragon!

    T 1 Reply Last reply
    0
    • S snailflying

      Now i have lots of text files in a folder,i want to combine them into one large file,but the problem is that it is must be order the formation rule. for instance:(the txt file order) the first text file list item"1c.txt,2c.txt,......... the second text file list item"1e.txt,2e.txt,........ now the combine file order must be "1c.txt,1e.txt,2c.txt,2e.txt........." and so on! Waiting for ur help! Thx advance!;P

      Don't try it, just do it! *Archibald*rever dragon!

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      algo : - find all file names to be combined - add each name to a vector of strings (with the strings being the file names) - write your functor to be used to sort the files list the way you like - use std::sort with your functor - create a new empty file - read each file in the order of the sorted vector and add its content at the end of the new file just created at the previous step - dont forget to close all remaining opened files. you got it


      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      S 1 Reply Last reply
      0
      • T toxcct

        algo : - find all file names to be combined - add each name to a vector of strings (with the strings being the file names) - write your functor to be used to sort the files list the way you like - use std::sort with your functor - create a new empty file - read each file in the order of the sorted vector and add its content at the end of the new file just created at the previous step - dont forget to close all remaining opened files. you got it


        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

        S Offline
        S Offline
        snailflying
        wrote on last edited by
        #3

        thank u very much! i know how to do it!:-O

        初学者!Don't try it, just do it! *Archibald*rever dragon!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups