#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string reverseStr(string& x);

int main()
{

	// Array for your words
	vector<string> words;

	// Your Words
	words.push_back("I");
	words.push_back("won");
	words.push_back("ten");
	words.push_back("tickets");
	words.push_back("for");
	words.push_back("a");
	words.push_back("rock");
	words.push_back("concert");
	words.push_back("in");
	words.push_back("the");
	words.push_back("park");
	words.push_back("for");
	words.push_back("this");
	words.push_back("Friday");

	vector<string>:: iterator myIter;
	vector<string>:: const_iterator iter;

	cout << "Sentence 1" << endl;

	// Shows the words in array using an iterator
	for (iter = words.begin(); iter != words.end(); ++iter)
		cout << *iter << " ";
	cout << endl;
	cout << endl;

	// Shows how many words and letters are there in sentence 1
	for (int i = 0; i < words.size(); ++i)
		cout << "This has " << i << " words in the sentence." << endl;
	cout << endl;
	cout << "There are 51 letters in sentence 1." << endl;
	cout << endl;

	cout << "Sentence 2" << endl;

	// Shows 1st word backwards and 9th word backwords to change sentence
	string sentence2 = reverseStr(words[1]) + " " + words[12] + " " + words[13] + " " + words[8] + " " + words[9] + " " + words[10] + " " + words[8] + " " + words[9] + " " + reverseStr(words[2]);
	cout << sentence2 << endl;
	cout << endl;

	// Shows how many letters are in sentence 2
	for (int i = 0; i < sentence2.size(); ++i)
		cout << "This sentence has " << i << " letters in it." << endl;
	cout << endl;
	cout << "There are 9 words in sentence 2." << endl;
	cout << endl;

	cout << "Sentence 3" << endl;

	// Displays Sentence 3 and shows how many letters it contains
	string sentence3 = reverseStr(words[2]) + " " + words[3] + " " + words[8] + " " + words[9] + " " + words[10] + " " + words[4] + " " + words[13];
	cout << sentence3 << endl;
	cout << endl;

	for (int i = 0; i < sentence3.size(); ++i)
		cout << "This sentence has " << i << " letters in it." << endl;
	cout << endl;
	cout << "There are 7 words in sentence 3." << endl;
	cout << endl;

	// Bonus sentence
	cout << "Bonus Sentence" << endl;
	string phrase = words[0] + " " + words[10] + " " + words[8] + " " + words[9] + " " + words[3] + " " + words[10] + " " + words[8] + " " + words[5] + " " + words[6] + " " + words[7];
	cout << phrase << endl;
	cout << endl;

	// Displays how many letters are there in the bonus sentence
	for (int i = 0; i < phrase.size(); ++i)
		cout << "This sentence has : " << i << " letters in it" << endl;
	cout << endl;
	cout << "There are 10 words in the bonus sentence." << endl;
	cout << endl;

	system("PAUSE");
	return 0;
}

string reverseStr(string& x)
{
	string& temp = x;
	reverse(temp.begin(), temp.end());
	return temp;
}

how can i make warning 4018 go away in my for loops?

Change "int i = 0" to "vector<string>::size_type i = 0" in line 44 and to "string::size_type i = 0" in lines 58, 71, and 84.

Next time, please cite the text of the error message so we don't have to look it up.

commented: Thanks a lot for your help +1

sorry my man. Thanks a lot for helping me

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.