| | |
Program calculate letter occurence in a sentence
Thread Solved |
•
•
•
•
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???
C Syntax (Toggle Plain Text)
#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; }
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.
•
•
•
•
Aiks, i really fresh in C. Your coding contain some element i never learn before.
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.
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.
![]() |
Similar Threads
- Program- calculate # of days between two days (C++)
- java program to calculate simple interest (Java)
- Using Loops to calculate totals in C Program (C)
- Can anyone suggest why this program doesn't calculate correctly? (Java)
- Need help with C program (C)
- sentence capitalizer (C++)
Other Threads in the C Forum
- Previous Thread: c Compiler (Not C++)
- Next Thread: binary
Views: 5302 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for C
api arguments array arrays binary binarysearch c++ char character code codes coke command conversion convert copy copyimagefile cpu database decimal directory dude dynamic ebook ebooks error exec factorial fgets file fork function functions getlasterror givemetehcodez grade graphics homework i/o input insert int integer lazy libcurl line linked linkedlist linux list lists locate logical_drives loop loops malloc matrix memory messagebox motherboard mysql no-effort opensource output path pause pointer pointers problem process program programming questions read recursion recursive recv reverse scanf single socketprograming socketprogramming spoonfeeding sql static string strings strtok structures student suggestions system systemcall turbo turbo-c turboc unix user variable windows





haha

