Thread: traverse a string array

  1. #16
    Registered User
    Join Date
    Mar 2006
    Posts
    23
    eh, make sense!

  2. #17
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    Code:
    size_t arrlen (void** arr)
    {
        size_t i;
        for (i = 0; arr[i] != NULL; i++);
        return i;
    }
    ?

  3. #18
    Registered User
    Join Date
    Mar 2006
    Posts
    23
    Is it required a NULL element in the array, as it's mentioned above?

  4. #19
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Correct. Here, as mentioned earlier, you're simply saying "stop on a null". There is nothing in the language that itself specifies such a terminator as the "right" way to count elements. And again, it requires that you actually place one there, for it to work the way they're using it.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  2. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM