Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Work with Array...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 45668 of 47992
Post > Topic >>

Work with Arrays

by Frank Liebelt <ecosys_@[EMAIL PROTECTED] > Apr 30, 2008 at 02:56 PM

Hi

I hope my english ist good enough to explain what my problem is.

I want to create a array with two dimensions. Each index should have a 
second dimension with three indexes.
Like: myarr[0][0-2] , myarr[1][0-2] and so on...

The size of the first dimension is unknown the second ist allways three.

In Detail:

I read an XML File and save all Values in an char* Array:

I tried to use a vector for this problem.
Within the headerfile i wrote: vector<char> arrSpec;

....
int listPos = -1;

// This resize works
arrSpec.resize(XMLCount)

while ( element ) {
char *id = NULL;
char *name = NULL;
char *path = NULL;

listPos++;

id = xmlGetAttribute(element, _id);
name = xmlGetAttribute(element, _name);
path = xmlGetAttribute(element, _path

arrSpec[listPos].resize(3);
arrSpec[listPos][0].push_back(id);
arrSpec[listPos][1].push_back(name);
arrSpec[listPos][2].push_back(path);
....

Now the Problem.
-> arrSpec[listPos].resize(3);
Wont work. I got the following compiler error:

---
test.cpp:222: error: request for member `resize' in `(((std::vector<char, 
std::allocator<char> >*)((TestClass*)this)) + 68u)->std::vector<_Tp, 
_Alloc>::operator[] [with _Tp = char, _Alloc = std::allocator<char>]
(((unsigned int)listPos))', which is of non-class type `char'
---

The next three line have this compiler error:
invalid types `char[int]' for array subscript

I think this is cause the resize faild. But not sure.

So i need any help to get this done. 

Frank
 




 4 Posts in Topic:
Work with Arrays
Frank Liebelt <ecosys_  2008-04-30 14:56:30 
Re: Work with Arrays
"Martin T." <  2008-04-30 16:01:41 
Re: Work with Arrays
"Eric.Malenfant@[EMA  2008-04-30 07:15:52 
Re: Work with Arrays
Frank Liebelt <ecosys_  2008-04-30 17:22:20 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 18:29:40 CDT 2008.