|
Hello,
I'm a beginner in C++ and I have to do a program which reads datas from a file and writes them in another. These files are really huge. My program (below)gives the good result, but I have a segmentation fault all the time, and the buffer x is not deleted. It may be a problem of memory but I don't know how to solve it...
Can you help me?
Thanks a lot for any reply.
Here is my program:
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
main()
{
char *nom=new char;
cout<<"nom?"<<endl;
cin>>nom;
ifstream fin (nom, ios::in);
ofstream fout("write", ios::out);
char *y=new char;
int n=0;
int s=0;
if (s==0){
for(int i=0; i<11; i++){
fin.seekg(20,ios::beg);
fin.get(y,10);
fout<<y<<endl;
}
}
else{
cout<<"rien"<<endl;
}
delete y;
delete nom;
fin.close();
fout.close();
}
|
|
|
|
|
|
|
|
|
// |