如何存储的可执行文件内的数据 [英] How to store data inside the executable file

查看:186
本文介绍了如何存储的可执行文件内的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一种方法来存储我的程序的可执行文件中明文数字的250 KB。

I need to find a way to store 250 KB of plain text numbers inside my program's executable file.

通常情况下,我想将数据放入一个单独的文件,并让程序读取它在运行时,但是这不是一个不错的选择。相反,程序和数据需要在一个可执行文件中。

Usually, I would put the data in a separate file and let the program read it while it is running, but that's not an option here. Instead, the program and the data need to be in one executable file.

我完全不知道该怎么做(除了写250.000的#define :-)和我最好的AP preciate任何建议。

I have absolutely no idea how to do it (except writing 250.000 #defines :-) and I'd appreciate any suggestions.

推荐答案

如何某种类型的数组。只要把这个定义在文件中并编译成你的程序:

How about an array of some sort. Just put that definition in a file and compile it into your program:

int external_data[] =
{
    ...
};

您可以让编译器告诉你有多少元素在外部数据:

you can have the compiler tell you how many elements are in external data:

size_t external_data_max_idx = sizeof(external_data) / sizeof(*external_data);

这篇关于如何存储的可执行文件内的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆