How to split a file other that .txt extension using C++ code

Aici puteti sta la un pahar de vorba cu ceilalti membri despre orice subiect.

How to split a file other that .txt extension using C++ code

Mesajde rolandbaker » 13 Apr 2017, 08:22

I've been looking for a solution to split a file with any file format, using C++. what i've found so far and tried as well, could only split .txt file. To split (say .docx) file into 2 files is possible, but to open splitted files give error. The same is true with other file formats. For example try the the code below with a different file extension rather than .txt or .dat (say .jpg).

is anyone who have a solution?

Best Regards,

#include<iostream>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
int main()
{
ifstream fin1, fin2;
ofstream fout;
char ch, file_name1[20], file_name2[20], file_name3[30];
cout<<"\n Enter First File Name with Extension !=.txt : ";
gets(file_name1);
cout<<"\n Enter Second File Name with Extension !=.txt : ";
gets(file_name2);
cout<<"\n Enter Third File Name with Extension !=.txt ";
cout<<"\n (which will Store the Contents of \n First File and Second File) : ";
gets(file_name3);

fin1.open(file_name1);
fin2.open(file_name2);
if(fin1==NULL || fin2==NULL)
{
cout<<"\n Invalid File Name. \n There is no such File ...";
exit(EXIT_FAILURE);
}
fout.open(file_name3);
if(!fout)
{
cout<<"\n Invalid File Name. \n There is no such File...";
exit(EXIT_FAILURE);
}
while(fin1.eof()==0)
{
fin1>>ch;
fout<<ch;
}
Thanks,
I didn't find the right solution from the internet.

References:

- http://www.cplusplus.com/forum/general/213097/



- Field Management Video Examples
rolandbaker
Junior
Junior
 
Mesaje: 29
Membru din: 25 Feb 2017, 15:38
Judet: Vaslui

Înapoi la Discutii

Cine este conectat

Utilizatorii ce navighează pe acest forum: Niciun utilizator înregistrat şi 5 vizitatori

cron