有的小說段落之間有大批的空行,看起來十分難看,比如:
長達500多頁,手動改就尷尬了,廢話不多少,直接上代碼:
#include "stdafx.h" #include <stdio.h> int main() { FILE * infile, * ofile; errno_t erri = fopen_s(&infile, "input.txt", "r"); errno_t erro = fopen_s(&ofile, "output.txt", "w"); char ch[2]; int ptr = 0; ch[ptr] = fgetc(infile); while(ch[ptr] != EOF) { if(ch[ptr] == '\n') { if(ch[1 - ptr] == '\n') {} else { fputc(ch[ptr], ofile); } } else { fputc(ch[ptr], ofile); } ptr = 1 - ptr; ch[ptr] = fgetc(infile); } return 0; }
把生成的TXT另存為PDF,這樣就好看多了: