SPRINTF()

this function formats and stores a series of characters and values (such as numbers) into a string. it is commonly used to convert numeric values like integers or floating-point numbers into their string representations, which can then be used for display, storage, or further string manipulation.

sprintf(str, "%d", number);

 * converts the integer number into a string stored in str
    - this function is the opposite of atoi and atof
    
 * format for multiple format string
    sprintf(message, "%
#include <stdio.h>

int main() {
    int number = 12345;           // Integer number to convert
    char str[20];                 // Character array to hold the string

    // Convert integer to string using sprintf
    sprintf(str, "%d", number);

    // Print the resulting string
    printf("Number as string: %s\n", str);

    return 0;
}

Last updated