Jukka Virtanen wrote:
can one convert a string of length one into a char?
ie the below wont work:
program t(input,output); var ch:char; s:string(10); begin s:='teststring'; writeln(substr(s,2,1)); ch:=substr(s,2,1); writeln(ord(ch)); end.
Yes, one can. The correct assignment reads
ch:= s [ 2 ];
I think, this is Standard Pascal, nothing special. At least, it is common between UCSD, Borland and GNU Pascal.
In extended pascal it is also allowed to assign a string to a char if the length of the string is 1, which is the case here.
you are welcome :)
but note that i _can_ do the assignment via:
readstr(substr(s,2,1),ch);
I think you found a bug in gpc, thanks for the report :-) Juki jtv@hut.fi