string(1) to char?_(re)
Thu, 30 Nov 1995 11:40:49 -0500
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
--
Thomas Dunbar 540 231-3938 (fax 3714) http://gserver.grads.vt.edu/
Thomas Dunbar (tdunbar@gserver.grads.vt.edu)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es