【发布时间】:2018-06-30 07:34:14
【问题描述】:
我目前正在制作一个加密/解密程序。加密后,结果存储在一个文本文件中,每个字符存储为一个十六进制值。 我目前正在解密,第一阶段是读取该文件,并将每个十六进制值存储为数组中的一个元素。
FILE * decryptIn = fopen("output.txt", "r");
fseek(decryptIn, 0L, SEEK_END); //counts the amount of bytes from start to end of file
int fileSize = ftell(decryptIn); //stores the size of the file in bytes
rewind(decryptIn); //sets offset back to 0 (back to start of file)
int *decryptHexArray = malloc(sizeof(int)*5*fileSize);
int currentPointer;
int counter = 0;
while(fgets(decryptHexArray[counter], fileSize, decryptIn)) //loop that reads each string from the file
{
counter++;
}
我得到的错误信息是
传递 'fgets' 的参数 1 使指针从没有 a 演员表
是否有可能用 fgets 实现我想要的?
【问题讨论】:
-
用十六进制你也可以有
A所以我认为最好只使用char数组 -
十六进制值如何分隔?你能假设空格分隔吗?每个数字前是否有前导
0x?