--
Hi all,
I am not new unix programer. But I having an amazing, to me, problem.
I write a program that read a file serching for to two integer, transform
in float and save into a complex vector. The code is lock like :
indice = 1;
while ( !(feof(input)) ) {
if ( read2int(cdata, input) ) {
perror(__FILE__);
return -1;
}
vector = realloc(vector, indice*sizeof(complex));
vector[indice-1] = cdata;
indice++;
}
read2int is just a routine that read to integer, test return of "fread"
function and errno for errors, transform the read integer in float. If
not errors was found this routine returns 0 elsewise -1 is returned.
Me test file have a 1024 pairs of integer, when the 1024-esimo integer pair
is read the while loop is even running.
What is the problem with may code?
Can I substitue the "!feof(input)" by
if ( ((fread(&intbuff, sizeof(int), 2, input)) == 0) && (errno==0) )?
Any suggestions?
Thank in advance
Hernn
Hernn J Cervantes Rodrguez
Instituto de Fsica da USP
homepage : http://fge.if.usp.br/~hernan/