Russell Whitaker a écrit:
Hi this program:
program writebug; var b1, b2: string (80); f: Text; begin Assign (f, 'ref.txt'); Reset (f); readln (f, b2); while not eof(f) do begin ReadLn (f, b1); if b1 [ 1 ] = '=' then writeln( b2, ' ':64 - length( b2 ), 'bug') else WriteLn ( b2); b2 := b1; end; writeln ( b1); Close (f); end.
Using either gpc built with gcc-3.3.3 or gcc-3.4.0
or gcc-3.2.3 ...
when b1 = '', i.e. length(b1) < 1, the test if b1 [1] = '=' then ... checks for the (invisible) contents which remains at this position from previous operations, i.e. the content of b1 beyond its actual length is not reset by reading. You were may be expecting such a reset or an error (trying to access invalid data, this would be logical but would break down many BP style constructs: filling the chars and afterwards setting the length)?
Maurice