Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add/update copyright notices.
[simgrid.git] / buildtools / Cmake / test_prog / prog_snprintf.c
1 /* Copyright (c) 2010, 2014. 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"))
16     exit(1);
17   if (i != 3)
18     exit(1);
19   i = snprintf(bufd, 2, "%d", 111);
20   if (strcmp(bufd, "1"))
21     exit(1);
22   if (i != 3)
23     exit(1);
24   exit(0);
25 }