User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,563 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,515 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 2858 | Replies: 13 | Solved
Reply
Join Date: Oct 2007
Posts: 26
Reputation: bobei89 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bobei89's Avatar
bobei89 bobei89 is offline Offline
Light Poster

Re: Program calculate letter occurence in a sentence

  #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  
Join Date: Oct 2007
Posts: 26
Reputation: bobei89 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bobei89's Avatar
bobei89 bobei89 is offline Offline
Light Poster

Re: Program calculate letter occurence in a sentence

  #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  
Join Date: Dec 2006
Posts: 1,569
Reputation: Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold Aia is a splendid one to behold 
Rep Power: 12
Solved Threads: 114
Aia's Avatar
Aia Aia is offline Offline
Posting Virtuoso

Re: Program calculate letter occurence in a sentence

  #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.
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.
Reply With Quote  
Join Date: Oct 2007
Posts: 26
Reputation: bobei89 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bobei89's Avatar
bobei89 bobei89 is offline Offline
Light Poster

Re: Program calculate letter occurence in a sentence

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

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC