Printing vectors

Hello everybody, I'm kinda stuck with a little problem. I hope you can help me.

I won't copy paste the whole source code, but just the important things. I have a structure like this:
1
2
3
4
5
struct project{
	vector<int> vTask;
	int finalDuration;
	bool mode;
};

Then, I define a class with some elements in it
1
2
3
4
class RACP{
private:
	vector<project> vProject;
	int nProj,nTask;

What I'm trying to do with this information, is this:
1
2
3
4
5
6
int RACP::find(int p,int x){
	for(int i=0;i<this->nTask;i++){
		if(this->vProject[p].vTask[i] == x) return -1;
	}
	return 0;
}

(p takes values between 0 and 19, x between 0 and 10, nTask=11)

My question:
How can I print (printf? cout?) the values for vProject[p] and vProject[p].vTask[i]? I tried printf but there isn't any specifier that is able to show the desired values.

A lot of thanks in advance to anyone who can help!
There're many ways to do it. This is one using the ostream_iterator:
1
2
3
vector<int> V;
// ...
copy(V.begin(), V.end(), ostream_iterator<int>(cout, "\n"));
Topic archived. No new replies allowed.