Vector<string> trouble

I am tryng to display a random vector string. The vector object gets randomized, but the problem is that it only displays the FIRST letter of the string! Any ideas?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

	vector<string> horses;

	vector<string>::const_iterator iter;

	horses.push_back("Red Rum");
	horses.push_back("Sampson");
	horses.push_back("Seabiscuit");
	horses.push_back("Man O' War");

	random_shuffle(horses.begin(), horses.end());

	iter = horses.begin();

	cout<<"The Horses are off!" <<endl;
	wait(1);
	cout<<"The Horses race out of the gate!"<<endl;
	wait(1);
	cout<< *iter->begin() <<" edges in front, not far from the finish!"<<endl;
	wait(1);
	cout<< *iter->begin() <<" is in the lead!"<<endl;
	wait(1);	
	cout<<"All the Horses are neck and neck!"<<endl<<endl;
	wait(4);


Thanks in advance :)
Last edited on
Operator precedence problem. It is dereferencing iter and then calling begin() on the string. Try *(iter->begin()).

Or even better: horses.front()

EDIT: Nevermind that! ;)
Last edited on
I tried *(iter->begin()) but I get the same result! :(
iter->begin() calls std::string::begin as iter is already an iterator
SOLVED! I was using <cstring> instead of <string> in my headers, it worked straight away then with cout << *iter;
Topic archived. No new replies allowed.