c***@gmail.com
2009-01-28 20:47:12 UTC
I need a octave script that can read a value from stdin,
print it, and continue this cycle until eof is reached.
My code:
while (!feof(stdin))
z = fscanf(stdin, "%f\n");
printf(">> %f <<\n", z);
printf("hello\n");
endwhile
The output for input values of "1", "2", and "3", ^D
There are two problems with this.
First, nothing is printed until ^D is reached.
And second, why is "hello" printed only once?
I've tried configuring the pager settings,
but I don't believe that is the problem.
I've also tried fflush(stdout) after the fprint() statements with no
effect.
Any help would be much appreciated.
print it, and continue this cycle until eof is reached.
My code:
while (!feof(stdin))
z = fscanf(stdin, "%f\n");
printf(">> %f <<\n", z);
printf("hello\n");
endwhile
The output for input values of "1", "2", and "3", ^D
1.000000 <<
2.000000 <<
3.000000 <<
hello2.000000 <<
3.000000 <<
There are two problems with this.
First, nothing is printed until ^D is reached.
And second, why is "hello" printed only once?
I've tried configuring the pager settings,
but I don't believe that is the problem.
I've also tried fflush(stdout) after the fprint() statements with no
effect.
Any help would be much appreciated.