我希望使用 OpenSSL 来加密文件中的文本,并且在加密之前需要将文本放在 unsigned char 数组中。从文件读取文本到无符号字符数组的最简单方法是什么?
Your question is tagged both C and C++ (which isn't constructive). I will give an answer for C++.
#include <fstream>
#include <iterator>
#include <vector>
using namespace std;
int main()
{
ifstream in("filename.txt"); //open file
in >> noskipws; //we don't want to skip spaces
//initialize a vector with a pair of istream_iterators
vector<unsigned char> v((istream_iterator<unsigned char>(in)),
(istream_iterator<unsigned char>()));
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)