Jump to content
  • Advertisement
Sign in to follow this  
hisDudeness

iterating arrays of unknown size

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
For a quick solution, I suggest using vectors over arrays. Arrays aren't meant to dynamically change in size; that's when vectors are preferred. It has a sizeof() function that returns the number of values in the vector.

Share this post


Link to post
Share on other sites
okay that was an easy example so i used a standard data type (int)...

let's say i have a class called Widget:

Widget w = getUserInput();
int i;
for(i = 0; i < w.length; i++) {}

will this work? do application-defined objects inherit the length member?

Share this post


Link to post
Share on other sites
I somehow doubt that you could inherit anything from a vector. However, if you meant to write Widget[] w, then you can still use w.length.

.length is a property provided by java to any and all arrays.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!