📄 example.cpp
字号:
#include <stdio.h>
#include "../comprlib.h" /* Link with: comprlib.o */
#include "../io/fileio.h"
}; /* What is that doing there? ;} */
int main(int argc, char* argv[])
{
int i;
if (argc != 5)
{
printf("Usage: %s method e/d input output\n", argv[0]);
printf("Methods: ");
for (i = 0; methods[i].name; ++i)
{
printf("%s ", methods[i].name);
}
return 0;
}
FILE* in = fopen(argv[3], "rb");
FILE* out = fopen(argv[4], "wb");
int (*encode)() = 0;
int (*decode)() = 0;
if (!in || !out) { printf("cannot open files"); return -1; }
FileIO::FileIO(in, out);
end_of_data = FileIO::end_of_data;
read_byte = FileIO::read_byte;
write_byte = FileIO::write_byte;
stream_size = FileIO::stream_size;
beginning_of_data = FileIO::beginning_of_data;
write_array = FileIO::write_array;
write_block = FileIO::write_block;
for (i = 0; methods[i].name; ++i)
{
if (!stricmp(methods[i].name, argv[1]))
{
encode = methods[i].encode;
decode = methods[i].decode;
break;
}
}
if (!encode || !decode) {
printf("No valid method selected, choose one of: ");
for (i = 0; methods[i].name; ++i)
{
printf("%s ", methods[i].name);
}
return -2;
}
if (argv[2][0] & 1) /* e(ncode) or another odd letter */
encode();
else /* d(ecode) or another even letter */
decode();
fclose(in);
fclose(out);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -