0

Hi!
It's me again :)
I have failed with my C++ code once again. This time it's with vectors.

string show_actions(){

	vector<string> actions;
	actions.push_back("end");
	actions.push_back("hunt");

	vector<string>::const_iterator iter;

	cout <<"All of the possible actions are : " << endl;
	for(iter = actions.begin(); iter != actions.end(); ++iter){
	cout << *iter << endl;
	
	}
}

There is supposed to be an error somewhere in that code. When I try to compile it prints out

end
hunt
Segmentation fault

If you know what to do, please let me know. I haven't got the slightest clue

If you need the rest of the code, it's located here. I don't think you will need to check it out though, because it compiles fine.
http://www.2shared.com/file/qtz5FEON/Lost_island.html
http://www.2shared.com/file/_0HuOq_j/island_func_mine_hunt.html
http://www.2shared.com/file/8K9sK3-4/island_func_hunt_rest.html
http://www.2shared.com/file/NIATZELS/island_func_build.html

Thanks!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Triarius
1

I don't see any return statement but you've specified the function to have a string return. Have you tried re-specifying the function as a void function so that you don't need the return statement?

Edited by Fbody: n/a

0

Thanks Fbody!
Now that I have specified it as void it works perfectly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.