// static.cpp -- using a static local variable
#include
// constants
const int ArSize = 10;
// function prototype
void strcount(const char * str);
int main()
{
using namespace std;
char input[ArSize];
char next;
cout cin.get(input, ArSize);
while (cin)
{
cin.get(next);
while (next != '\n') // string didn't fit!
cin.get(next);
strcount(input);
cout cin.get(input, ArSize);
}
cout return 0;
}
void strcount(const char * str)
{
using namespace std;
static int total = 0; // static local variable
int count = 0; // automatic local variable
cout while (*str++) // go to end of string
count++;
total += count;
cout cout }