Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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);
}
 
PREVIOUS NEXT
Tagged: #read #file #vector
ADD COMMENT
Topic
Name
8+8 =