LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-04-2004, 01:51 PM   #1
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Rep: Reputation: 30
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
 
Old 11-05-2004, 10:00 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,293

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
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
 
Old 11-05-2004, 10:52 AM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,161
Blog Entries: 4

Rep: Reputation: 136Reputation: 136
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.
 
Old 11-05-2004, 11:36 AM   #4
flamesrock
Member
 
Registered: Aug 2003
Distribution: Gentoo 2006.1
Posts: 405

Original Poster
Rep: Reputation: 30
thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if users exist in the system hindll01 Programming 12 09-28-2012 03:24 PM
get_alias_user_groups: gid of user 00sarahl doesn't exist. Check your /etc/passwd and seanfitz Linux - Networking 0 09-30-2005 08:06 AM
Check if email exist or not proNick Linux - Software 2 08-27-2005 02:25 PM
How to check if a software exist in my computer Niceman2005 Linux - Newbie 4 12-28-2004 10:12 PM
script to check $PATH directories exist Frustin Linux - Software 3 09-21-2004 01:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration