[lazarus] convert edit.text to pchar ?

Michael Van Canneyt michael.vancanneyt at wisa.be
Thu Jun 28 03:44:13 EDT 2001

On Wed, 27 Jun 2001, NORBERT ALLAIN wrote:

> I want convert a string in a edit component in a pchar (i use a c
> fonction in a dynamic library)

Just do a typecast:


But beware:
the resulting string is only valid for the duration of the particular statement
it is in, i.e. the C function should consider it a 'const' argument.

If you want a more 'permanent' string, you'll have to use strnew() to allocate
a new string on the heap, but then it must also explicitly be released:

  ... // use P as much as needed.


More information about the Lazarus mailing list