Program calculate letter occurence in a sentence

Thread Solved

Join Date: Oct 2007
Posts: 26
Reputation: bobei89 is an unknown quantity at this point 
Solved Threads: 0
bobei89's Avatar
bobei89 bobei89 is offline Offline
Light Poster

Re: Program calculate letter occurence in a sentence

 
0
  #11
Oct 21st, 2007
Originally Posted by Aia View Post
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???
  1. #include <stdio.h>
  2. /* #define ALL_CHARACTER */ /* enable for use all characters in RANGE */
  3. /* #define RANGE */ /* enable for only lower case */
  4. #ifdef RANGE
  5. #define START 'a'
  6. #endif
  7. #ifndef RANGE
  8. #define START 'A'
  9. #endif
  10.  
  11. int main( void )
  12. {
  13. char character[256] = { 0 };
  14. int c = '\0';
  15.  
  16. puts( "Enter some text:" );
  17.  
  18. while ( ( c = getchar() ) != '\n' && c != EOF )
  19. {
  20. ++character[c];
  21. }
  22. for ( c = START; c <= 'z'; c++ )
  23. {
  24. #ifndef ALL_CHARACTER
  25. if ( character[c] )
  26. #endif
  27. printf( "%c = %d\n", c, character[c] );
  28. }
  29. getchar();
  30. return 0;
  31. }

Aiks, i really fresh in C. Your coding contain some element i never learn before. haha But thx, i copy paste the code and run it, it work perfectly.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 26
Reputation: bobei89 is an unknown quantity at this point 
Solved Threads: 0
bobei89's Avatar
bobei89 bobei89 is offline Offline
Light Poster

Re: Program calculate letter occurence in a sentence

 
0
  #12
Oct 21st, 2007
Originally Posted by ithelp View Post
Cannot you use std::string apis ?
i never learn about it. haha
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,097
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 185
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: Program calculate letter occurence in a sentence

 
0
  #13
Oct 21st, 2007
Originally Posted by bobei89 View Post
Aiks, i really fresh in C. Your coding contain some element i never learn before.
Learning is a process always on going.
Originally Posted by bobei89 View Post
i copy paste the code and run it, it work perfectly.
No copy and paste. Write it. Practice. Write it again. Practice again.
You'll learn nothing by just coping and paste and looking at it, and rejoicing that it works.
You don't know that it works until you understand why it does.

Originally Posted by bobei89 View Post
Cannot you use std::string apis ?
>i never learn about it. haha
That's not C. Don't pay attention to it.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan stating how a liberal's mind works.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 26
Reputation: bobei89 is an unknown quantity at this point 
Solved Threads: 0
bobei89's Avatar
bobei89 bobei89 is offline Offline
Light Poster

Re: Program calculate letter occurence in a sentence

 
0
  #14
Oct 22nd, 2007
Yosh, Thank you all who reply my thread. Problem solved.
Thx alot ya.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 5302 | Replies: 13
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC