Hi guys,
Just wanted to ask you're opinions about this program I had to write for evening school, the idea is when you enter a phrase wich isn't longer then 80 letters, the programm will count the amount of each letter wich is written :!:
It doesn't have to keep account of 'a' or 'A', and I had to show each letter of the alphabet, just in case you we're wondering.
So, if you could just give me some pointers ;) in wich way I could improve it, I would appreciate very much :)
// AantalLetters.cpp : Johan Berntzen: 11/11/2004
#include <stdafx.h>
#include <iostream.h>
#include <iomanip.h>
int zoek(const char s[], char ch);
void main(void)
{
int amount=0;
char str[80], letter='a';
cout<< " Write a phrase: ";
cin.getline(str,80);
for (int i=0;i<26;i++)
{
amount=zoek(str, letter);
cout<< letter << " = "<< amount;
cout<<setw(8);
if(i%7==6)cout<<endl;
letter++;
}
cin.get();
}
int zoek(const char s[], char ch)
{
short a=0;
for (int i=0;i<s[i];i++)
{
if (s[i]==ch)
a=++a;
}
return a;
}