Files
RedBear-OS/tests/sprintf.c
T
Dan Robertson 75920d2c12 Add implementations of sprintf and snprintf
Add implementations of sprintf and snprintf so that we can get a bit
closer to compiling libc-test.
2018-03-10 02:33:03 +00: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;
}
}