Jump to content
  • Advertisement
Sign in to follow this  
KaiDao

[C++] Multidimensional Arrays question

This topic is 3658 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

Hey guys, I was wondering if there was any way that I could access the size (or length) of a string element inside a multidimensional array. I tried using (ARRAY[x][y]).size to access the size, but it gave me a compile error. I did get past this problem by using a switch statement, but I was just wondering, is there any way to access the size of the string? Thanks, Kai.

Share this post


Link to post
Share on other sites
Advertisement
You can (and probably should) use Boost.MultiArray. It's designed to handle exactly what you're after. Also, its overhead is minimal if existent at all.

Example:
boost::multi_array<float, 3> my_array(boost::extents[12][13][14]);

my_array[0][0][0] = 4;

Share this post


Link to post
Share on other sites
You mean, you have a multidimensional array of strings, and you want to find the length of a particular string in that array? If you're talking about std::strings, then no problem:
std::string array[10][10];
//do stuff that puts stuff in the strings here
int size = array[3][6].size();

Share this post


Link to post
Share on other sites
HAHAHA oops. I made a very careless error. As stated above..I used array[x][y].size...I forgot the parenthesis...

Thanks for the answer and I'll look more into Boost.MultiArray

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!