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!

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?

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

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.