Uses C file handling functions to edit files.
A simple C program that takes input as text from a file, removes trailing and unnecessary blank spaces and also wraps the line after a given length.
compile and run the main.c file as follows :
First change the permission for build.sh file.
$ chmod +x build.sh
$ ./build.sh
Compile the program as follows:
$ gcc main.c White-Spacing.c Statistics.c pattern.c -o format
$ ./format <Input file-name> <Output file-name>
$ ./format in.txt out.txt // in this case.
$ ./format <file-name> find <string>
$ ./format in.txt Programming // in this case.
$ ./format <file-name> stats
$ ./format in.txt stats // in this case.
Here, “in.txt“ is the example input file, and “out.txt“ is the output file after formatting. Notice, in “in.txt“ the text is widespread and not formatted properly.
After the program finishes running, have a look at the out.txt, notice that the formatting should have been improved. The file “in.txt“ can contain any input and it would remove trailing white spaces and unnecessary white spaces between the words and also wraps line for you.
Here, “in.txt“ and “out.txt“ is just used as an example.