hstrip.cpp
来自「非常好用的五子棋游戏源码」· C++ 代码 · 共 75 行
CPP
75 行
// Created:11-14-98
// By Jeff Connelly
// HStrip - Reduces the size of HTML documents
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h>
#include <ctype.h>
bool iswhitespace(char c)
{
switch (c)
{
case 0x0A: // fall though
case 0x0D: // fall though
case ' ': // fall though
case 0x09: return true;
default: return false;
};
}
// Reduces the size of HTML page 'in' to 'out'
void ReduceHTML(FILE* in, FILE* out)
{
bool whitespace = false;
register char c;
while (!feof(in))
{
c = getc(in);
if (iswhitespace(c))
whitespace = true;
else
{
if (whitespace) // Whitespace was present
fputc(' ', out);
fputc(c, out);
whitespace = false;
}
}
}
const char* help = "Reduces the size of an HTML page\n"
"\tHSTRIP source dest\n"
"\n";
int main(int argc, char* argv[])
{
FILE* in;
FILE* out;
if (argc != 3)
{
printf(help);
exit (0);
}
in = fopen(argv[1], "rt");
out = fopen(argv[2], "wt");
if (!in || !out)
{
printf ("Cannot open files(s)\n");
exit (1);
}
printf ("Reducing size of %s...\n", argv[1]);
ReduceHTML(in, out);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?