Mail Archives: cygwin/2008/05/09/04:44:23
Hi all!
First of all hello everybody! because I've just joined
the list. I've had a lok into the Mailing list archive and I've seen
that this error has happened before to other people but each time the
solution was different and I haven't found the answer to my specific
case so here we go!
I'm just trying to read a .data file and create a .xls file to use
with excel; for that I've created the next simple program:
#include <stdio.h>
main (int argc, char* argv[])
{
FILE *f1, *f2;
char *file_name;
int num_compressors = 0;
int num_files = 0;
int numC = 0;
char *out_file;
char *aux;
char *ctime;
if(argc != 2)
{
fprintf(stderr, "Use: %s nameOfFile\n", argv[0]);
exit(1);
}
// Open source file
if ((f1 = fopen(argv[1],"r")) == NULL){
fprintf(stderr, "Can't open %s\n", argv[1]);
exit(1);
}
fprintf(stderr, "%s opened\n", argv[1]);
fscanf(f1,"%d",&num_compressors
);
fprintf(stderr, "Number of compressors: %d\n", num_compressors);
fscanf(f1,"%d",&num_files);
fprintf(stderr, "Number of files: %d\n", num_files);
do{
// THE PROBLEM SEEMS TO BEGIN HERE
fscanf(f1,"%s",out_file);
fprintf(stderr, "Name of compressor: %s\n", out_file);
out_file = strcat(out_file, ".xls");
fprintf(stderr, "Read name of the new file: %s\n", out_file);
// Create new .xls file
f2 = fopen (out_file, "w");
if (f2==NULL){
fprintf(stderr, "Can't open %s\n", out_file);
exit(1);
}
fscanf(f1,"%s",file_name);
fprintf(f2, "%s\t", file_name);
fscanf(f1,"%s %s", aux, ctime);
fprintf(f2, "%s\t", ctime);
numC++;
}while (numC < num_compressors);
fclose(f1);
fclose(f2);
}
The test .data file is called pruExcel.data and consist of:
1
1
gzip
to_mm_24.bin
real 0m0.614s
user 0m0.499s
sys 0m0.015s
And the output :
$ ./oExcel pruExcel.data
pruExcel.data opened
Number of compressors: 1
Number of files: 1
7 [main] oExcel 2988 _cygtls::handle_exceptions: Error while dumping state
(probably corrupted stack)
Segmentation fault (core dumped)
I'm working with Windows XP and CYGWIN_NT-5.1,
any idea would be appreciated!
Thanks!
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -