-
May 3rd, 2012, 01:54 PM
#1
[RESOLVED] vector question
Hello,
I have the following code below which crashes:
Code:
ifstream file("filename.txt");
vector<vector<unsigned char> > maxvec;
maxvec.resize(10*1024);
for(unsigned int i = 0; i < 10; i++)
{
for(unsigned int j = 0; j < 1024; j++)
{
int temp;
file >> temp;
maxvec[i][j] = temp;
}
}
I guess it does not like how I assign to the vector. What is the correct way to do this?
Thanks!
Alex
-
May 3rd, 2012, 02:07 PM
#2
Re: vector question
Code:
maxvec.resize(10*1024);
resizes the outer vector to have 10k empty vectors of unsigned chars.
use
Code:
maxvec.resize(10, vector<unsigned char>(1024));
Kurt
-
May 4th, 2012, 07:22 AM
#3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|