codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  segmentation fault...please, I need help!  gaelles at 23:19 on Tuesday, August 02, 2005
 

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();
}

  Re: segmentation fault...please, I need help!  vector at 12:40 on Saturday, May 20, 2006
 

Just do this

cin>>*nom;









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  onChange issue
•  Remote program execution using cgi-perl
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007