Never define
main as
void return. Start defining main as
int main( void ) or
int main ( int argc, char *argv[] ) if you are expecting arguments from the command line.
>Sorry i never learn about <ctype.h>, isalpha, islower and isupper, is there other way???
#include <stdio.h>
/* #define ALL_CHARACTER */ /* enable for use all characters in RANGE */
/* #define RANGE */ /* enable for only lower case */
#ifdef RANGE
#define START 'a'
#endif
#ifndef RANGE
#define START 'A'
#endif
int main( void )
{
char character[256] = { 0 };
int c = '\0';
puts( "Enter some text:" );
while ( ( c = getchar() ) != '\n' && c != EOF )
{
++character[c];
}
for ( c = START; c <= 'z'; c++ )
{
#ifndef ALL_CHARACTER
if ( character[c] )
#endif
printf( "%c = %d\n", c, character[c] );
}
getchar();
return 0;
}
Last edited by Aia : Oct 21st, 2007 at 1:02 am.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.