string to Char coonversion

is there any way to convert "D" as a string type into "D" as a char type with Delphi 3?
arintAsked:
Who is Participating?
 
aluikenConnect With a Mentor Commented:
yeah sure

Procedure WhatEver(S : String);
Var Ch : Char;
Begin
 Ch := S[1];
End;

now ch will contain the first char of string <S>

thats it,

regards Arijan
0
 
arintAuthor Commented:
Edited text of question
0
 
itamarCommented:
What about ?

var
  St : String;
  Ch : PChar;
begin
  Ch := PChar(St);
  ...
end;

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
JimBob091197Commented:
itamar's answer will convert string to PChar.  If you want to convert string to Char, try this:

var
  c: PChar;
  s: string;
begin
  c := ' ';
  if (Length(s) > 0) then
    c := @s[1];
  ...
end;

JB
0
 
JimBob091197Commented:
P.S.  Should read
    c := s[1];
NOT
    c := @s[1];

JB
0
 
itamarCommented:
HEI !

Isn't this "proposed answer" the JimBob's comment put as an answer ?? :<
0
 
aluikenCommented:
yeah but if you leave the question open it's easy point's !!
0
 
JimBob091197Commented:
You clearly have a good idea of the spirit in which Experts Exchange is run...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.