LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to check if array[0] doesn't exist? (https://www.linuxquestions.org/questions/programming-9/how-to-check-if-array%5B0%5D-doesnt-exist-251125/)

flamesrock 11-04-2004 12:51 PM

How to check if array[0] doesn't exist?
 
newb question:

In pascal (gpc), how do I check if a position in a certain array is not occupied? (for char arrays and real arrays) Will it contain 0?

Can I use the null or void keywords with gpc?
(I'm not familiar with pascal..)


-thanks

Guttorm 11-05-2004 09:00 AM

Well, an array, all "positions" are always occupied - if you have an array of integeres, there's no way for any position to not be occupied. It's value might not be initialized though.

If it's an array of pointers, you can use the special value nil (similar to C's NULL) to mean that it doesn't point to anything.

Hope this helps,
Guttorm

vharishankar 11-05-2004 09:52 AM

Initialize all elements of your array to a special value that indicates that a position is not occupied (maybe -1 or 0 or something).

So that you can check against that value to see if an element is empty or not.

flamesrock 11-05-2004 10:36 AM

thanks :)


All times are GMT -5. The time now is 11:56 PM.