Solved

string to Char coonversion

Posted on 1997-12-14
8
6,874 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?
0
Comment
Question by:arint
  • 3
  • 2
  • 2
  • +1
8 Comments
 

Author Comment

by:arint
Comment Utility
Edited text of question
0
 
LVL 4

Expert Comment

by:itamar
Comment Utility
What about ?

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

0
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
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
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
P.S.  Should read
    c := s[1];
NOT
    c := @s[1];

JB
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Accepted Solution

by:
aluiken earned 50 total points
Comment Utility
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
 
LVL 4

Expert Comment

by:itamar
Comment Utility
HEI !

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

Expert Comment

by:aluiken
Comment Utility
yeah but if you leave the question open it's easy point's !!
0
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
You clearly have a good idea of the spirit in which Experts Exchange is run...
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now