Sprintf

xiaoxiao2021-03-06  103

Sprintf () formatted output function (graphics)

Function: The function sprintf () is used to format the output.

Usage: This function call mode is int Sprintf (char * string, char * format, arg_list);

Note: The usage of function sprintf () is the same as the Printf () function, just the sprintf () function gives the first parameter String (generally a character array), then call the OutTextxy () function to display the characters in the screen on the screen. . Arg_list is a parameter table, may have a number. Usually, when the number is used in the drawing mode, you can call the SPRINTF () function to send the format of the desired output to the first parameter, then display the output.

Function Name: Sprintf function: send formatted output to string Usage: int sprintf (char * string, char * farmat [, argument, ...]);

#include #include

INT main (void) {char buffer [80];

Sprintf (Buffer, "An Approximation Of PI IS% F / N", M_PI); PUTS (Buffer);} Sprintf's role is to output a formatted string into a destination string, and Printf is Out of a formatted string to the screen. The first parameter of the sprintf should be a destination string. If this parameter is not specified, "the program generates illegal operations during the execution" The program will be turned off, which is about to be closed ... " Because the C language does not check if the space is not checked in a string operation, there may be a problem that the array crimp can cause the program crash. Even if you happen, the program doesn't have an error, and it should not be used because it will be mistaken. So be sure to assign a large enough space to BUF before calling the Sprintf.

转载请注明原文地址:https://www.9cbs.com/read-102521.html

New Post(0)