How can i read in an array and then count the number of words that end in punctuation? Thanks for any insight.

U can use standard container routine as "vector".

steps:
1. read char
2. check
3. push_back

then "size" of vector will be the length of sentence.

regards

Teddy

well, if you just need to count the number of words that end in punctuation, you do not need to store it in an array or a vector first. assuming that words are whitespace separated, read word by word into a std::string till there is nothing more.

std::string word ;
while( std::cin >> word )
{
  // process it
}

to get the last character of the word

if( !word.empty() )
{
   char last_char = word[ word.size()-1 ] ;
   // check if it a punctuation, if yes increment a count
}

to check if a char is a punctuation in the input locale, use std::ispunct (#include <cctype>)

const std::locale& input_locale = std::cin.getloc() ; 
if( std::ispunct( last_char, input_locale ) ) ++count ;

if you also need to store the words read for access later, add each word to a std::vector<string>

strlen for counting nuber of words :

for reading and counting I use.


for( i=0 ; a != '\0' ; i++)
{
cout<<a;
length++;
}