Thread: Array size in C as in Java?

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    178

    Array size in C as in Java?

    In Java one can use foo.size or foo.size() if an ArrayList to determine the size of an array. Quite handy for keeping "ArrayIndexOutOfBound" exceptions from being thrown but in C is there anything even remotely close to this?

    I would rather there be than to continuously write a function to determine the size of an array.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    There is not a similar function in C. Easiest way is to keep a second variable, an int, to track the size.

    However, C++ has equivalent methods.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    178
    Thanks Dino.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of array
    By goran00 in forum C Programming
    Replies: 38
    Last Post: 04-02-2008, 09:57 AM
  2. Invalid conversion from 'void*' to 'BYTE' help
    By bikr692002 in forum C++ Programming
    Replies: 9
    Last Post: 02-22-2006, 11:27 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. Replies: 11
    Last Post: 03-25-2003, 05:13 PM