read file into vector
std::vector<char> vec;
if (FILE *fp = fopen("filename", "r"))
{
char buf[1024];
while (size_t len = fread(buf, 1, sizeof(buf), fp))
{
v.insert(vec.end(), buf, buf + len);
}
fclose(fp);
}
read file into vector
std::vector<char> vec;
if (FILE *fp = fopen("filename", "r"))
{
char buf[1024];
while (size_t len = fread(buf, 1, sizeof(buf), fp))
{
v.insert(vec.end(), buf, buf + len);
}
fclose(fp);
}
copy file to vector c++
//Read file to the end
while(inFile.read(reinterpret_cast<char*>(&temp), sizeof(temp)))
{
//Store each int in the vector
myVector.push_back(temp);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us