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]

Reading txt file


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?

Thanks in advance
Best regards.
Giovanni Perbellini



-- 
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]