This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reading txt file


On Mon, Apr 28, 2003 at 11:56:33AM +0200, Giovanni Perbellini wrote:
> Hi all,
> I have a simple program to read from text file.
> This is the source code:
> 
> source.h
> 
> #include <stdio.h>
> class source {
> 	public:
> 		source();
> 		FILE *fp_real;
> 		FILE *fp_imag;
> 		bool getValue(float *real, float *imag);
> };
> 
> source.cc
> 
> #include "source.h"
> source::source() {
> 	fp_real = fopen("in_real", "r");
> 	fp_imag = fopen("in_imag", "r");
> }
> bool source::getValue(float *real, float *imag) {
> 	bool bool_eof;
> 	bool_eof = true;
>     if (fscanf(fp_real,"%f \n",real) == EOF) {
> 		//cout << "End of Input Stream: Simulation Stops" << endl;
> 		bool_eof = false;
> 	};
>     if (fscanf(fp_imag,"%f \n",imag) == EOF){
> 		//cout << "End of Input Stream: Simulation Stops" << endl;
> 		bool_eof = false;
> 	};
> 	return bool_eof;
> }
> 
> I compile the file without problem, but when I simulate the file with
> arm-elf-gdb (target sim) I get a problem when I read, using fscanf, from
> file....the program stops!Where is the error?

What filesystem are you using? I presume its a ROM fs? How do you load
the contents of the filesystem? Do you remember to mount the
filesystem?

Also, this list is here to help you debug your own problems. You have
to show us what you have found out and we can help you interpret the
information. So, information like, where does it stop? Does it at
least call fopen? Do fopen return an error? The more information you
give us the better.

     Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]