Peter Gerwinski wrote:
Why is this correct? Isn't Text, being declared as an array of char, treated as a 0-terminated string, meaning that the #0 should not be printed?
No. Text being declared as an array of char is treated as a string of fixed length. The Standard doesn't say anything about 0-termination. If GPC sometimes takes `chr ( 0 )' as the end of a string, this behaviour is a remainder of the C back-end and should be reported as a BUG. (I am not, however, speaking of `CString's (= `PChar's) which are a GNU (resp. Borland) extension.)
Then we have a conflict with BP (the first real one)-: ! The following writes '1.' with BP, and '1[#0]2.' with gpc (regardless of the state of --borland-pascal and --extended-syntax): program x; const a:array[0..3] of char='1'#0'2'#0; begin writeln(a,'.') end. Any ideas how to solve the conflict -- or how to do something equivalent to the BP meaning of this program in gpc at all? Do we need another compiler switch...? And, why is there no #0 output after the '2'? Is this a bug? Ooops, can't gpc write PChars at all? The following doesn't work: program x; {$x+} var a:PChar; begin writeln(a) end. Similarly, the following compiles with BP, but not with gpc: program x; {$x+} var a:PChar; begin a:='Test' {in BP: assign the address of the 0-terminated string 'Test'#0 (stored somewhere statically) to a} end. -- Frank Heckenbach, Erlangen, Germany heckenb@mi.uni-erlangen.de Turbo Pascal: http://www.mi.uni-erlangen.de/~heckenb/programs.htm Internet links: http://www.mi.uni-erlangen.de/~heckenb/links.htm