Hi all,
I'm not very proficient in C but I'm trying to translate a block of code to Pascal. I think it's getting unstuck because the original code is using pointers while I'm using arrays.
The original code is:
unsigned long *prefix;
unsigned char *suffix;
unsigned char *stack;
unsigned char *stackptr;
prefix
= (unsigned long*)malloc(sizeof(unsigned long) * (max
+ 1)); suffix
= (unsigned char*)malloc(sizeof(unsigned char) * (max
+ 1)); stack
= (unsigned char*)malloc(sizeof(unsigned char) * (max
+ 1)); stackptr = &stack[0];
Then the stack is accessed thus (just a random line I picked out):
prefix and suffix are accessed, however, via:
*stackptr++ = suffix[code];
code = prefix[code];
So, onto Pascal and mine is:
stackptr : Cardinal;
prefix : array of Cardinal;
suffix,
stack : array of Byte;
and accessed thus:
stack[stackptr]:=firstchar;
inc(stackptr);
Now the code doesn't do what it is supposed to, so I'm assuming that the problem may lie here. It could be else where, but I'm eliminating the possible to narrow it down.
Oh, I haven't really delved into using pointers in Pascal before, so this won't help!!