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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

vector of arrays in c++

Reply to Message Icon

Original Message
Name: sciguy125
Date: June 22, 2005 at 12:08:16 Pacific
Subject: vector of arrays in c++
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.



Report Offensive Message For Removal


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

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.


Report Offensive Follow Up For Removal







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








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software