sptest.cpp

来自「非常好用的五子棋游戏源码」· C++ 代码 · 共 59 行

CPP
59
字号
// Created:10-31-98
// By Jeff Connelly

// Spinning cursor example while encoding/decoding

// Compile: gcc sptest.cpp -o sptest.exe -lcompr

#include "comprlib.h"

// This is a custom function to read a byte
unsigned char spin_read_byte()
{
    // The prototype for spin() is:
    //     void spin(int speed = 10, char chars[] = "|/-\\\0");
    // speed        The numbers of characters that must be read
    //              before the characters are spun. (1 in this example)
    // chars[]      The characters, in order, to spin, null-terminated
    //              (the default |/-\ is OK)
    spin(1);        // Spin after one character is read.

    // Now actually read the byte
    return ComprLibFileIO::read_byte();
}

int main(int argc, char* argv[])
{
    // Set all of the I/O function pointers to file I/O
    ComprLibFileIO::Set();

    // Assign the function pointer to read a byte to our custom one
    read_byte = spin_read_byte;

    if (argc != 3)
    {
        printf ("Compresses a file using LZSS and displays a spinning cursor.\n"
                "Syntax: SPTEST source dest\n"
                "Example: sptest sptest.exe sptest.cmp");
        exit (1);
    }

    ComprLibFileIO::source_file = fopen(argv[1], "rb");
    ComprLibFileIO::dest_file = fopen(argv[2], "wb");

    if (!ComprLibFileIO::source_file || !ComprLibFileIO::dest_file)
    {
        printf ("Failed to open file(s)\n");
        exit (1);
    }

    printf ("The spinning cursor: ");

    lzss_encode();

    fclose(ComprLibFileIO::source_file);
    fclose(ComprLibFileIO::dest_file);
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?