![]() |
| | #1 |
| Registered User Join Date: Jul 2003
Posts: 32
| Is there a way to find the number of elements in an array? Say you have two arrays and you want to make a single function to print the out the elements. One is size 2 and one is size 3 let's say. Is there a way to read the number of elements in an array so that you don't print out 3 elements if you're printing the array with 2 elements? |
| lime is offline | |
| | #2 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,643
| Or you could always do something odd like use the first element of the array to hold the total number of elements in the array. Code: char array[100] = {100};
Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? |
| quzah is offline | |
| | #3 |
| Registered User Join Date: Jul 2003
Posts: 32
| would NELEM(x) also work for arrays of pointers? |
| lime is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| xor linked list | adramalech | C Programming | 23 | 10-14-2008 10:13 AM |
| using realloc for a dynamically growing array | broli86 | C Programming | 10 | 06-27-2008 05:37 AM |
| Template Array Class | hpy_gilmore8 | C++ Programming | 15 | 04-11-2004 11:15 PM |
| Struct *** initialization | Saravanan | C Programming | 20 | 10-09-2003 12:04 PM |
| Can't find the lowest number in array? | Nate2430 | C++ Programming | 1 | 11-20-2001 10:21 AM |