Solved

String and pChar

Posted on 1998-06-03
3
406 Views
Last Modified: 2010-08-05
I should assign a String-Value to a pChar-Variable. But the Compiler (Delphi 3 Prof) sais, 'incompatible types'. So is there any way to convert a String into a pChar ? I should use that, because the origin of the data, the String is stored in a binary file, more exactly in an array of string in that file. I used string, becuz it seems, the program couldn't read the pChar-Value exactly when I wrote ArrayName[IndexVar] (I got only a part of the data back).

I cannot change what the function expects, it wants a pChar, so best way will probly be to do a convert from String to pChar, but how ?

thanx :)
0
Comment
Question by:omsec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
BlackMan earned 50 total points
ID: 1350018
Use StrPCopy (see helpfile for documentation)
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1350019
or use TypeCasting:

var A: pChar;
     B: String;
begin
  B:='Example';
  A:=pChar(B);
end;
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1350020
Also if you know the length that will be returned in the pchar use SetLength(myString,newlength) to set the length of the string;

Rick
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

624 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