Suppose I write a couple paragraphs and save it as apple.txt. How do I put this file into an array and remove the blank spaces.
Suppose I write a couple paragraphs and save it as apple.txt. How do I put this file into an array and remove the blank spaces.
>How do I put this file into an array and remove the blank spaces.
Removing the blank spaces is easy if you plan to write the array back to the file, simply print the non-whitespace characters to the file. The problem comes in placing the input in an array, it's not terribly difficult, but simply writing from the input file to an output file without the spaces is much easier and more efficient since you don't have to shuffle an array or create a second buffer:
-PreludeCode:while ( ( ch = fgetc ( instream ) ) != EOF ) if ( !isspace ( ch ) ) fputc ( ch, outstream );
My best code is written with the delete key.