How would you fill a 2d vector with NULL.

I've tried doing

vector<vector<int> > data;
           data (10, vector<int> (10,NULL))

But I get an error, and I've also tried setting it to NULL through two for loops and that produces an error as well.

Can someone point out what I'm doing wrong and show me how to fill a 2d vector with NULL?

Recommended Answers

All 2 Replies

NULL is used for pointers, not integers. Just call vector's resize() method if you want to have a 10x10 matrix of integers, and you have to resize() each row of the vector individually in a loop. The resize() method will set the values to 0.

Thanks, works fine.

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.