Hi,
So how exactly do we take the length of an int array? Lets say that there is an array called int nums []={2, 1, 2, 3, 4};
Is there a function that can be used to find it?
mathgirlgrade6
0
Newbie Poster
Recommended Answers
Jump to PostIn this case you can
sizeof
.sizeof
returns the amount of Bytes the element is using. So the idea is to find thesizeof(array)
(in your case which will be 20) and thesizeof(int)
. The size of an int is 4 Bytes.So now you can use the Math and …
Jump to PostNext time show some code ok?
int foo = sizeof(array)/sizeof(int);
All 8 Replies
mathgirlgrade6
0
Newbie Poster
kal_crazy
13
Junior Poster
richieking
44
Master Poster
mathgirlgrade6
0
Newbie Poster
mathgirlgrade6
0
Newbie Poster
mathgirlgrade6
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Donald_6
-2
Newbie Poster
rproffitt
commented:
Check those discussion dates.
-2
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.