about summary refs log tree commit diff
path: root/lib/util/testnstring.c
blob: 87e6139e7981b83054e74dc405879f94f4cc6b69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#include "nstring.h"

#define true (1)
#define false (0)

int
main(int argc, char **argv) {

    char snprintfNResult[80];
    const char * asprintfNResult; 

    printf("Hello world.\n");

    snprintfN(snprintfNResult, 19, "snprintfN test truncated");

    printf("snprintfN result='%s'\n", snprintfNResult);

    asprintfN(&asprintfNResult, "asprintf'ed string %d %u %s", 
              5, 89, "substring");

    printf("asprintfN result='%s'\n", asprintfNResult);

    strfree(asprintfNResult);
    return 0;
}