[cpp] Created input/output section.
This commit is contained in:
parent
4700702ea5
commit
6518bba15f
@ -87,12 +87,24 @@ snippet ns
|
|||||||
namespace ${1:`Filename('', 'my')`} {
|
namespace ${1:`Filename('', 'my')`} {
|
||||||
${2}
|
${2}
|
||||||
} /* namespace $1 */
|
} /* namespace $1 */
|
||||||
|
##
|
||||||
|
## Input/Output
|
||||||
# std::cout
|
# std::cout
|
||||||
snippet cout
|
snippet cout
|
||||||
std::cout << ${1} << std::endl;
|
std::cout << ${1} << std::endl;
|
||||||
# std::cin
|
# std::cin
|
||||||
snippet cin
|
snippet cin
|
||||||
std::cin >> ${1};
|
std::cin >> ${1};
|
||||||
|
# read file into vector
|
||||||
|
snippet readfile
|
||||||
|
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}
|
||||||
|
|
||||||
# for i loop
|
# for i loop
|
||||||
snippet fori
|
snippet fori
|
||||||
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||||
@ -116,13 +128,3 @@ snippet itera
|
|||||||
${2:std::cout << *$1 << std::endl;}
|
${2:std::cout << *$1 << std::endl;}
|
||||||
}
|
}
|
||||||
|
|
||||||
# read file into vector
|
|
||||||
snippet readfile
|
|
||||||
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}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user