Computing.Net > Forums > Programming > vector of arrays in c++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

vector of arrays in c++

Reply to Message Icon

Name: sciguy125
Date: June 22, 2005 at 12:08:16 Pacific
OS: na
CPU/Ram: na
Comment:

I've been trying to make a vector of arrays in c++:

vector<char[16]>

but, apparently, that doesn't work. So, I've been trying to figure out how to make

vector<vector<char> >

but I need the char vectors to be 16 long. I can't have them initialized to 0 length because I need random access to them.

If I have

vector<vector<char> > data

I need to be able to do data[i][n] = something. However, if data[i] is 0 length, which it will be when it's initialized, I won't be able to.




Sponsored Link
Ads by Google

Response Number 1
Name: livingdecay
Date: June 26, 2005 at 01:55:55 Pacific
Reply:

Why dont u use a vector of strings? As far as I know a string is basically a vector of chars anyway.
#include <string.h>
#include <vector.h> //whatever the header file is
int main()
{
vector<string>
...
}

I dont know if this'll work, just a thought.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: vector of arrays in c++

internal structudre of Array in C++ www.computing.net/answers/programming/internal-structudre-of-array-in-c/939.html

How to use string array in C++? www.computing.net/answers/programming/how-to-use-string-array-in-c/9478.html

Dynamic Arrays in C www.computing.net/answers/programming/dynamic-arrays-in-c/3396.html