BadAppleStringAnimation icon indicating copy to clipboard operation
BadAppleStringAnimation copied to clipboard

一些问题

Open yuwuweichun opened this issue 1 year ago • 2 comments

make-错误

yuwuweichun avatar Nov 08 '23 15:11 yuwuweichun

在visual studio 2022中新建项目 不确定是否是选择了不恰当的选项而导致出现问题 新建项目时,如下: windows桌面向导→控制台应用程序→空项目

文件详情 文件详情

运行结果 无法找到指定文件

Debug文件详情 debug文件详情

在Debug中确实没有BadApple_song.exe文件,我现在在试图解决这个问题。

yuwuweichun avatar Nov 09 '23 04:11 yuwuweichun

在本地编译运行 新建项目,将BadApple.txt文本文档添加在项目文件夹内 对main.c中的代码做了一些修改,以便在visual studio 2022中成功运行: 1.#pragma warning(disable:4996) 禁用visual studio 2022中fopen,strtok警告 可以使用fopen_s,strtok_s代替,但是参数部分也需要做更改 2.#include <windows.h> void usleep(unsigned int microseconds) { Sleep(microseconds / 1000); } 使用 Sleep 函数替代 usleep 函数

#include <stdio.h> #include <windows.h> #include <stdlib.h> #include <string.h> #pragma warning(disable:4996)

#ifndef PATH #define PATH "badapple.txt" #endif

#define EQUALS(x, y) (strcmp(x, y) == 0)

static size_t delay = 50000; void usleep(unsigned int microseconds) { Sleep(microseconds / 1000); }

int main(int argc, char const* argv[]) { for (int i = 1; i < argc; i++) { if (EQUALS(argv[i], "-d")) delay = strtol(argv[++i], NULL, 0); else if (EQUALS(argv[i], "-h") || EQUALS(argv[i], "--help")) { printf( "badapple\n" "\n" "Usage:\tbadapple <-d delay> <-h,--help>\n" "\n" "-h,--help\tShow this help page\n" "\n" "-d\t\tSet delay between frames\n" "\n" "Author: kisekied https://github.com/kisekied\n" ); exit(EXIT_FAILURE); } }

FILE* fp = fopen(PATH, "r");
fseek(fp, 0, SEEK_END);
int file_size = ftell(fp);
printf("%d\n", file_size);
char* tmp;
fseek(fp, 0, SEEK_SET);
tmp = (char*)malloc(file_size * sizeof(char));
fread(tmp, file_size, sizeof(char), fp);
char* delim = "nekomark";
char* p = NULL;

p = strtok(tmp, delim);
while (p != NULL)
{
	system("clear");
	printf("%s", p);
	usleep(delay);
	p = strtok(NULL, delim);
}

return EXIT_SUCCESS;

} 这是一个极其丑陋的解决方法

yuwuweichun avatar Nov 09 '23 15:11 yuwuweichun