dotar/vim/snippets/c/readfile.snippet

8 lines
198 B
Plaintext
Raw Normal View History

2011-11-18 05:45:33 +08:00
std::vector<char> v;
if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
char buf[1024];
while (size_t len = fread(buf, 1, sizeof(buf), $2))
v.insert(v.end(), buf, buf + len);
fclose($2);
}${3}