bar graph for character count?

Hi. i am working on an assignment to count the amount of words, sentences and questions in a string, and also output the amount of characters and the number of times they occur in a bar graph.

This is the code i have so far.

#include <iostream>
using namespace std;
int main()
{
char mytext[200];
char ch = 'x';
int i;
int a;
int words = 0;
int sentences = 0;
int questions = 0;
int counts [256] = {0};
int drawBar (int x);
cout << "enter some text: ";
gets(mytext);
a = strlen(mytext);
cout << "you typed: " << mytext << endl;
cout << "length: " << a << endl;
for (i=0;i<=a-1;i++)
{
ch = mytext[i];
switch(ch)
{
case ' ':
words++;
break;
case '.':
sentences++;
words++;
break;
case '?':
questions++;
sentences++;
words++;
}
}
cout << "Words: " << words << endl;
cout << "Sentences: " << sentences << endl;
cout << "questions: " << questions << endl;
system("pause");
return 0;
}
int drawBar (int x)
{
int i = 0;
for (i=0;i<=x-1;i++)
{
cout << "*";
}
cout << endl;

return 0;
}

What am i doing wrong?
Topic archived. No new replies allowed.