Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a33c8467fb5959320587e55798bab81890935bd8
[simgrid.git] / buildtools / Cmake / prog_test / prog_snprintf.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stdio.h>
8
9 int main(void)
10 {
11     char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
12     char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
13     int i;
14     i = snprintf (bufs, 2, "%s", "111");
15     if (strcmp (bufs, "1")) exit (1);
16     if (i != 3) exit (1);
17     i = snprintf (bufd, 2, "%d", 111);
18     if (strcmp (bufd, "1")) exit (1);
19     if (i != 3) exit (1);
20     exit(0);
21 }