more stuff too lazy to seperate
This commit is contained in:
@ -54,4 +54,26 @@ ls.add_snippets('c', {
|
||||
}
|
||||
)
|
||||
),
|
||||
s({
|
||||
name = 'Variadic function parser',
|
||||
trig = 'infinite vars',
|
||||
dscr = 'Parse an infinite number of arguments passed to a function',
|
||||
},
|
||||
{
|
||||
t({
|
||||
"/*",
|
||||
" * NOTE: the function must have a int before the ... argument",
|
||||
" * and you need to include <stdarg.h> for this to work",
|
||||
" */",
|
||||
"va_list ptr;",
|
||||
"va_start(ptr, ", i(1, "n"),
|
||||
");",
|
||||
"for (int i = 0; i < ", ri(1),
|
||||
"; i++) {",
|
||||
i(2),
|
||||
"}",
|
||||
"va_end(ptr);",
|
||||
}),
|
||||
}
|
||||
)
|
||||
})
|
||||
|
Reference in New Issue
Block a user