We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

string to Char coonversion

arint
arint asked
on
Medium Priority
6,911 Views
Last Modified: 2012-05-04
is there any way to convert "D" as a string type into "D" as a char type with Delphi 3?
Comment
Watch Question

Author

Commented:
Edited text of question

Commented:
What about ?

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

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
P.S.  Should read
    c := s[1];
NOT
    c := @s[1];

JB
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
HEI !

Isn't this "proposed answer" the JimBob's comment put as an answer ?? :<

Commented:
yeah but if you leave the question open it's easy point's !!
You clearly have a good idea of the spirit in which Experts Exchange is run...
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.