Recent

Author Topic: how to convert this simple c code to pascal?  (Read 3390 times)

billyb123

  • New Member
  • *
  • Posts: 26
how to convert this simple c code to pascal?
« on: November 18, 2017, 01:36:05 am »
its simple variable definition, not really experienced in pascal, whats the pascal variation of following c code?

Code: [Select]
char *blabla[] =
{
    "qwerty",
    "asdfg",
    "message",
    "this is"
};

so, i need blablab to be of type PPChar, how to define it to match the above?
« Last Edit: November 18, 2017, 01:40:00 am by billyb123 »

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: how to convert this simple c code to pascal?
« Reply #1 on: November 18, 2017, 12:25:52 pm »
so, i need blablab to be of type PPChar, how to define it to match the above?
PPChar ?

Isn't it an array of PChar, as char  * is a pointer to a char (Pascal equivalent is PChar) and blabla[] is an array ?

Code: [Select]
const
  blabla : array[0..3] of PChar = (
    'qwerty',
    'asdfg',
    'message',
    'this is'
  );

billyb123

  • New Member
  • *
  • Posts: 26
Re: how to convert this simple c code to pascal?
« Reply #2 on: November 18, 2017, 01:02:17 pm »
i simplified the question.. i need PPChar in a certain function but will try to pass array of pchar to it (it is the same thing)..

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: how to convert this simple c code to pascal?
« Reply #3 on: November 18, 2017, 01:19:08 pm »
In case PPChar is required then don't forget to close your array with a nil as that is th usual way to close such an array. Other then that, you should be good to go.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: how to convert this simple c code to pascal?
« Reply #4 on: November 18, 2017, 06:17:06 pm »
i simplified the question.. i need PPChar in a certain function but will try to pass array of pchar to it (it is the same thing)..
I assume your actual question is: "how to pass an array of pchar to a function expecting ppchar". In that case just pass @ArrayOfPChar[LowestIndex].

billyb123

  • New Member
  • *
  • Posts: 26
Re: how to convert this simple c code to pascal?
« Reply #5 on: November 18, 2017, 06:36:51 pm »
Thanks for the replies guys

 

TinyPortal © 2005-2018