I have some sentence fragments and some words. I need to print out sentence1 + word + sentence2 capitalize the first charater in sentence1. Then, sentence3 + word + sentence4 capitalize sentence

right now it is printing the first sentence capitalized + word + second sentence
second sentence not capital + word + first sentence capital
third sentence captial + word + first sentence capital

for (i = 0; i < index; i++)
	{
		//Converts 1st character in each sentence to uppercase
		if ( i % 2 == 0)
		fragments[i][0] = toupper(fragments[i][0]);
		//Prints out entire char array

		std::cout << fragments[i] << " " << words[i] << " " << fragments[i % 2 ==0] << "." << " " << endl;
	}

I think you need to count the sentences and words independently -- that is use a different index for each. I didn't compile or test this, but something like this might work.

int sindex = 0; // sentence counter
int windex = 0; // word index

for(int i = 0; i < NumfragmentsInArray; i += 2)
{
     string line = fragments[sindex++]; // sentence1
     line  += words[windex++];
     line += fragments[sindex++]; // sentence2
     line[0] = toupper(line[0]); // capatilize
    cout << line << "\n";
}
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.