/* takes an input file, removes all the vowels, and puts that into the given output file */ int disemvowel(FILE* inputFile, FILE* outputFile){ int num_chars; int num_cons; char in_buf[BUF_SIZE]; num_chars = fread(in_buf, sizeof(char), BUF_SIZE, inputFile); char out_buf[num_chars]; num_cons = copy_non_vowels(num_chars, in_buf, out_buf); fwrite(out_buf, sizeof(char), num_cons, outputFile); return num_cons; }
void disemvowel(FILE* inputFile, FILE* outputFile) { /* * Copy all the non-vowels from inputFile to outputFile. * Create input and output buffers, and use fread() to repeatedly read * in a buffer of data, copy the non-vowels to the output buffer, and * use fwrite to write that out. */ char* in_buf = calloc(BUF_SIZE, sizeof(char)); char* out_buf = calloc(BUF_SIZE, sizeof(char)); int size_vowels = fread(in_buf, sizeof(char), BUF_SIZE, inputFile); int size_no_vowels = copy_non_vowels(size_vowels, in_buf, out_buf); fwrite(out_buf, sizeof(char), size_no_vowels, outputFile); free(in_buf); free(out_buf); }