Files
RedBear-OS/tests/stdio/sprintf.c
T
2018-07-22 11:24:50 +02:00

31 lines
567 B
C

#include <stdio.h>
int main(int argc, char ** argv) {
char buffer[72];
int ret = sprintf(
buffer,
"This string fits in the buffer because it is only %d bytes in length",
68
);
if (ret) {
printf("Failed! %d\n", ret);
return -1;
}
ret = snprintf(
buffer,
72,
"This string is way longer and does not fit in the buffer because it %d bytes in length",
87
);
if (!ret) {
return 0;
} else {
printf("Failed! %d", ret);
return -1;
}
}