有没有办法在编译时将整个文本文件作为字符串包含在C程序中?
就像是:
file.txt的:
This is
a little
text file
Run Code Online (Sandbox Code Playgroud)main.c中:
#include <stdio.h>
int main(void) {
#blackmagicinclude("file.txt", content)
/*
equiv: char[] content = "This is\na little\ntext file";
*/
printf("%s", content);
}
Run Code Online (Sandbox Code Playgroud)获取一个在stdout上打印的小程序"这是一个小文本文件"
目前我使用了一个hackish python脚本,但它只是丑陋而且仅限于一个变量名,你能告诉我另一种方法吗?
我有一个C++ Windows程序.我有一个包含一些数据的文本文件.目前,文本文件是一个单独的文件,它在运行时加载并进行解析.如何将它作为资源嵌入到二进制文件中?
我试图在我的c ++程序中包含大字符串,它的大小是20598617个字符,我#define用来实现它.我有一个包含此语句的头文件
#define "<huge string containing 20598617 characterd>"
Run Code Online (Sandbox Code Playgroud)
当我尝试编译程序时,我得到错误 fatal error C1060: compiler is out of heap space
我尝试了以下命令行选项但没有成功
/Zm200
/Zm1000
/Zm2000
Run Code Online (Sandbox Code Playgroud)
如何成功编译此程序?
平台:Windows 7