Feb 26, 2005 #1 S sacrpio Member level 3 Joined May 24, 2004 Messages 56 Helped 1 Reputation 2 Reaction score 1 Trophy points 1,288 Activity points 500 INT ARRAY IN C Dear Friend, I have an int array, i want to find it's length how i can do. Array contains 0 also. Suppose following is the array I have to find it's length. Please Help!!!! int hello[]={1,2,3,0,4,3,9,7,5,6,0,6};
INT ARRAY IN C Dear Friend, I have an int array, i want to find it's length how i can do. Array contains 0 also. Suppose following is the array I have to find it's length. Please Help!!!! int hello[]={1,2,3,0,4,3,9,7,5,6,0,6};
Feb 26, 2005 #2 C C-Man Advanced Member level 4 Joined Jul 19, 2001 Messages 1,059 Helped 90 Reputation 180 Reaction score 17 Trophy points 1,318 Activity points 10,189 Re: INT ARRAY IN C Try: sizeof(hello) best regards
Feb 26, 2005 #3 Z Zerox100 Full Member level 6 Joined Mar 1, 2003 Messages 328 Helped 21 Reputation 42 Reaction score 10 Trophy points 1,298 Activity points 2,604 Re: INT ARRAY IN C sizeoff (int_array); But if you pass this vector to a fuction by refrence you must pass its length to function, because "sizeoff (int_array);" will not work correctly at this function.
Re: INT ARRAY IN C sizeoff (int_array); But if you pass this vector to a fuction by refrence you must pass its length to function, because "sizeoff (int_array);" will not work correctly at this function.
Feb 26, 2005 #4 E echo47 Advanced Member level 6 Joined Apr 7, 2002 Messages 3,933 Helped 638 Reputation 1,274 Reaction score 90 Trophy points 1,328 Location USA Activity points 33,176 INT ARRAY IN C The word "length" is unclear. sizeof(hello) is the number of bytes. sizeof(hello)/sizeof(*hello) is the number of elements.
INT ARRAY IN C The word "length" is unclear. sizeof(hello) is the number of bytes. sizeof(hello)/sizeof(*hello) is the number of elements.
Mar 3, 2005 #5 devennan Member level 3 Joined May 7, 2004 Messages 66 Helped 5 Reputation 10 Reaction score 1 Trophy points 1,288 Location India Activity points 798 Re: INT ARRAY IN C Algo get the sizeof Array sizeof(Array), It will give you sizeof(data type)*number of elements in Array then get size of data type sizeof(*data type) last sizeof(Array)/sizeof(*data type) this will give you total number of elements in Array got it gr8 Deven devennan@yahoo.com
Re: INT ARRAY IN C Algo get the sizeof Array sizeof(Array), It will give you sizeof(data type)*number of elements in Array then get size of data type sizeof(*data type) last sizeof(Array)/sizeof(*data type) this will give you total number of elements in Array got it gr8 Deven devennan@yahoo.com
Apr 1, 2005 #6 S sshahid47 Full Member level 1 Joined Nov 5, 2004 Messages 99 Helped 15 Reputation 30 Reaction score 2 Trophy points 1,298 Activity points 974 INT ARRAY IN C Hi, the simplest way i think is num of elements = sizeof(hello)/ sizeof(int)
Apr 1, 2005 #7 S shafee001 Advanced Member level 4 Joined May 6, 2004 Messages 114 Helped 16 Reputation 32 Reaction score 4 Trophy points 1,298 Location Egypt Activity points 1,078 INT ARRAY IN C yes it's the easy way sizeof(array)/sizeof(int);