I need to capitalize the first word of each sentence from a text file and make the rest lowercase. the text file looks like this:

April 7, 2010!
here is some TEST data
to see if THE prOGRAm will
work. "what do you know!"
wiLL IT?

anything with '.' '!' '?' qualifies as the end of a sentence, but sometimes the end of a sentence isnt always a punctuation mark ie: know!"

my code so far will capitalize the first letter of every word and makes the rest lowercase. Any tips on how to capitalize only the start of a sentence ?

void reformat(string& word)
{
  int wlen;
  wlen = word.length();
  word[0] = toupper(word[0]);
  for (int i=1; i<wlen; i++)
    word[i] = tolower(word[i]);
}

What constitutes the end of a sentence? Look for it and set a flag for EndOfSentence. Then next letter you find, capitalize it and clear EndOfSentence.

you must know end punctuation of every sentence, or you can store possible end flags into a container , such as vector or array, search the end punctuation from container and compare

I need to capitalize the first word of each sentence from a text file and make the rest lowercase. the text file looks like this:

April 7, 2010!
here is some TEST data
to see if THE prOGRAm will
work. "what do you know!"
wiLL IT?

anything with '.' '!' '?' qualifies as the end of a sentence, but sometimes the end of a sentence isnt always a punctuation mark ie: know!"

my code so far will capitalize the first letter of every word and makes the rest lowercase. Any tips on how to capitalize only the start of a sentence ?

void reformat(string& word)
{
  int wlen;
  wlen = word.length();
  word[0] = toupper(word[0]);
  for (int i=1; i<wlen; i++)
    word[i] = tolower(word[i]);
}

im stuck too mayb should try arrays,.,idk

I need to capitalize the first word of each sentence from a text file and make the rest lowercase. the text file looks like this:

April 7, 2010!
here is some TEST data
to see if THE prOGRAm will
work. "what do you know!"
wiLL IT?

anything with '.' '!' '?' qualifies as the end of a sentence, but sometimes the end of a sentence isnt always a punctuation mark ie: know!"

my code so far will capitalize the first letter of every word and makes the rest lowercase. Any tips on how to capitalize only the start of a sentence ?

void reformat(string& word)
{
  int wlen;
  wlen = word.length();
  word[0] = toupper(word[0]);
  for (int i=1; i<wlen; i++)
    word[i] = tolower(word[i]);
}

you do a for loop as well for the first part with the toupper();
you just need to get the first word's length and u do a for loop for that in the sammer manner as did for the rest of the sentence....the only exception is that this new for loop will only capitalize the first word....your quite close to finishing

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.