/* sprintf()関数 */
#include <stdio.h>

int main(void)
{
char buffer[80];
double x = 1234.5, y = 678.9, z = -753.1, a = x * y + z;

int output_len = sprintf(buffer, "For the input values %f, %f, and %f,"
"\nthe result was %f.\n", x , y, z, a);
puts(buffer);
/* if (output_len >= 80)
{
fprintf(stderr, "Output string overflowed by %d characters.\n"
"The variables x, y, z and a may have been corrupted:\n"
"x now contains %f, y %f, z %f, and a %f.\n",
output_len - 79, x, y, z, a);
} */
}

Reply via email to