mirror of
https://github.com/tailix/libkernaux.git
synced 2026-08-15 11:00:07 -04:00
Add "examples/snprintf[_va].c"
This commit is contained in:
parent
b3aed09ce9
commit
d1105f1cc6
5 changed files with 61 additions and 3 deletions
22
examples/snprintf.c
Normal file
22
examples/snprintf.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <kernaux/printf.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
static char buffer[BUFFER_SIZE];
|
||||
|
||||
int main()
|
||||
{
|
||||
const int result = kernaux_snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"Hello, %s! Session ID: %u.",
|
||||
"Alex",
|
||||
123
|
||||
);
|
||||
assert((size_t)result == strlen(buffer));
|
||||
assert(strcmp(buffer, "Hello, Alex! Session ID: 123.") == 0);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue