[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] ERROR: fscanf failed
From: |
Hélio Guilherme |
Subject: |
Re: [Help-gsl] ERROR: fscanf failed |
Date: |
Mon, 24 Jul 2006 20:56:23 +0100 |
User-agent: |
Thunderbird 1.5.0.2 (X11/20060420) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Fred J. wrote:
> Hi
> I am getting this error "ERROR: fscanf failed" upon running the c++ program
> below, the docs says "The function returns 0 for success and GSL_EFAILED if
> there was a problem reading from the file."
> in this case it is returning neither, rather somthing totally different.
>
> thanks for helping
(...)
Fred,
Here is my contribute to help you (although I don't know much C++ and
not a GSL expert). I also read your other posts here.
I read your C++ program and looks fine. But I have some questions:
- - is the C++ type string fully compatible with char * ?
- - are you sure about the path of the file? (would C++ throw an exception
if fopen fail?) I would go for a file in the same directory of the
executable. You file path seems too long, I would check that.
A basic library is the stdio.h, do you know if you have Linux
Programmer's Manual installed, that you can do:
$ man stdio
or
$ man fopen
That way you have the help for C language essential functions.
I recommend to study the gsl_matrix_fscanf (f, m) function, I'm sure
that you will understand how it is working.
Good luck.
> void read_data::matrix_the_file(){
> // allocate memory for the matrix
> // needs to be freed later using
> // void gsl_matrix_free (gsl_matrix * m)
> m = gsl_matrix_alloc (nRows, nCol);
> FILE * f = fopen(file_name.c_str(), "rb");
> gsl_matrix_fscanf (f, m);
> fclose(f);
> cout << "data read" << endl;
> }
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFExSXmHvesJJ5UqvkRAqI/AKD66DWnpaQvSRzsoPW+q4+++gwWFQCfcvxM
zCO3hUSdbJWfWqn2yA+25yM=
=33Lz
-----END PGP SIGNATURE-----