vector<vector <vector<char>>> Sub;
	Sub[0][0].push_back(s[0]);Sub[0][0].push_back('\0');
	Sub[0][1].push_back('\0');

I have the above code and it says "vector subscript insaccessible" for the assignments.What could the reason?
Thanks in advance,
Prasanna

Recommended Answers

All 4 Replies

vector<vector <vector<char> > > Sub;

Insert spaces in btw and it will be fine. Without spaces compiler will parse it as ">>" rather than "> >".

vector<vector <vector<char> > > Sub;

Insert spaces in btw and it will be fine. Without spaces compiler will parse it as ">>" rather than "> >".

No.It does't make any difference.Tried.Thanks for the reply though.
Anybody? I have not given a size to the vector.Could it be because of that?
Thanks again.

>> I have not given a size to the vector.Could it be because of that?

Well, if your vectors are empty, how could you expect to be able to access elements of them? I think people reading your example assumed it was not real code, just an example of the syntax that was erroneous.

Is your error occurring when you run the program or when you compile it?

You have to populate a vector with elements before you can access any. That's pretty obvious.

>> I have not given a size to the vector.Could it be because of that?

Well, if your vectors are empty, how could you expect to be able to access elements of them? I think people reading your example assumed it was not real code, just an example of the syntax that was erroneous.

Is your error occurring when you run the program or when you compile it?

You have to populate a vector with elements before you can access any. That's pretty obvious.

It's a run-time error.I'm new with vectors.Anyway figured it out.Thanks anyway.Peace!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.