Recent

Author Topic: newbie question - how to write this C code in pascal  (Read 2948 times)

whatsup

  • Jr. Member
  • **
  • Posts: 59
newbie question - how to write this C code in pascal
« on: June 27, 2013, 01:12:19 pm »
const char *Str1[] = {
  "p1",
  "p2",
  "p3"
};

thanks in advanced

v.denis

  • Guest
Re: newbie question - how to write this C code in pascal
« Reply #1 on: June 27, 2013, 01:23:13 pm »
const
  Str1: array [0..2] of PChar = (
    'p1',
    'p2',
    'p3'
  );

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4695
  • I like bugs.
Re: newbie question - how to write this C code in pascal
« Reply #2 on: June 27, 2013, 01:26:45 pm »
... or maybe :

Code: [Select]
const
  Str1: array [0..2] of string = (
    'p1',
    'p2',
    'p3'
  );

You don't need a pointer type in Object Pascal for this.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: newbie question - how to write this C code in pascal
« Reply #3 on: June 27, 2013, 01:43:33 pm »
const
  Str1: array [0..2] of PChar = (
    'p1',
    'p2',
    'p3'
  );
thank you very much.

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: newbie question - how to write this C code in pascal
« Reply #4 on: June 27, 2013, 01:44:35 pm »
... or maybe :

Code: [Select]
const
  Str1: array [0..2] of string = (
    'p1',
    'p2',
    'p3'
  );
thank you very much, but i'm using freepascal dialect.

You don't need a pointer type in Object Pascal for this.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: newbie question - how to write this C code in pascal
« Reply #5 on: June 27, 2013, 05:32:42 pm »
Quote
thank you very much, but i'm using freepascal dialect.
This feature doesn't require object oriented programming features, the freepascal dialect supports all strings as in other dialects.

 

TinyPortal © 2005-2018