Solved

String and pChar

Posted on 1998-06-03
3
400 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
3 Comments
 
LVL 7

Accepted Solution

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

Expert Comment

by:ronit051397
Comment Utility
or use TypeCasting:

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

Expert Comment

by:rickpet
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

8 Experts available now in Live!

Get 1:1 Help Now