1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2025-04-28 17:47:27 -04:00
libkernaux/examples/io_memstore.c

32 lines
758 B
C

#include <kernaux/io.h>
#include <assert.h>
#include <string.h>
#define BUFFER_SIZE 4096
static const char *const hello = "Hello, World!";
static char buffer[BUFFER_SIZE];
void example_main()
{
{
struct KernAux_MemStore mem_store =
KernAux_MemStore_create(buffer, BUFFER_SIZE);
assert(KernAux_Store_puts(&mem_store.store, hello));
assert(strncmp(buffer, hello, strlen(hello)) == 0);
}
memset(buffer, 0, sizeof(buffer));
{
struct KernAux_MemStore mem_store;
KernAux_MemStore_init(&mem_store, buffer, 5);
assert(!KernAux_Store_puts(&mem_store.store, hello));
assert(strncmp(buffer, hello, 5) == 0);
assert(strncmp(buffer, hello, strlen(hello)) != 0);
}
}