Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define START 0
- #define CAPITAL_WORD 1
- #define WORD 2
- #define DOT 3
- int main()
- {
- FILE *datoteka;
- char c, temp[30];
- if((datoteka = fopen("test.txt", "r")) == NULL ){
- printf("GRESKA!!!");
- return -1;
- }
- c = fgetc(datoteka);
- do{
- int count = 0;
- int token = START;
- if( c >= 'A' && c <= 'Z'){
- token = CAPITAL_WORD;
- temp[count] = c;
- c = fgetc(datoteka);
- while( c >= 'a' && c <='z' ){
- count++;
- temp[count] = c;
- c = fgetc(datoteka);
- }
- temp[++count] = '\0';
- printf("\nCAPITAL WORD \t\t %s", temp);
- }else if ( c >= 'a' && c <= 'z' ){
- token = WORD;
- while( c >= 'a' && c <= 'z' ){
- temp[count] = c;
- count++;
- c = fgetc(datoteka);
- }
- temp[count] = '\0';
- printf("\nWORD \t\t\t %s", temp);
- }else if( c == ' ' || c == '\n' ){
- c = fgetc(datoteka);
- }else if ( c== '.' ){
- token = DOT;
- printf("\nDOT \t\t\t %c", c);
- c = fgetc(datoteka);
- }else{
- printf("\nError \t\t\t %c", c);
- c = fgetc(datoteka);
- }
- }while( c != EOF );
- return 0;
- }
Add Comment
Please, Sign In to add comment