From 6518bba15ff54e61a5196b540219ec498bf999a7 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Tue, 28 Aug 2012 09:43:20 -0700 Subject: [PATCH] [cpp] Created input/output section. --- snippets/cpp.snippets | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index ed7be50..1ccdc51 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -87,12 +87,24 @@ snippet ns namespace ${1:`Filename('', 'my')`} { ${2} } /* namespace $1 */ +## +## Input/Output # std::cout snippet cout std::cout << ${1} << std::endl; # std::cin snippet cin std::cin >> ${1}; +# read file into vector +snippet readfile + std::vector 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 snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { @@ -116,13 +128,3 @@ snippet itera ${2:std::cout << *$1 << std::endl;} } -# read file into vector -snippet readfile - std::vector 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} -