/ Published in: C

Expand |
Embed | Plain Text
#include <stdio.h> #include <malloc.h> int main() { const int l_block = 1024; FILE* input_text_file; long n = 0, i = 0, j = 0; int meet_comma = 0; long file_lengh; char* buffer; int num_block; input_text_file = fopen( "../../additional_files/en.txt", "r" ); if ( !input_text_file ) { puts( "Can't open file!" ); return 1; } fseek( input_text_file, 0, SEEK_END ); file_lengh = ftell( input_text_file ); buffer = (char*) malloc( (file_lengh + 1) * sizeof(char) ); num_block = file_lengh / l_block; fseek( input_text_file, 0, SEEK_SET ); fread( buffer, l_block, num_block + 1, input_text_file ); buffer[file_lengh] = '\0'; /* ----------------------------- PROCESSING ------------------------------ */ while( buffer[i]) { switch ( buffer[i] ) { case ',': meet_comma = 1; break; case '.': case '!': case '?': if ( !meet_comma ) /* ЕÑли запÑтой небыло. */ for ( j = n; j <= i; j++ ) putchar( buffer[j] ); meet_comma = 0; n = i + 1; break; default: break; } i++; } /* ------------------------------------------------------------------------- */ fclose ( input_text_file ); free(buffer); puts(""); return 0; }
You need to login to post a comment.