Printf and Sprintf in C - Printf and Sprintf in C Programming Language



Printf and Sprintf in C Programming Language

Learn c - c tutorial - Printf and Sprintf in C Programming Language - c examples - c programs

Printf and Sprintf in C Programming Language

Printf()

  • Type of operate functions predate C and different names are used notably "format" is known as printf. Printf format strings which provide formatted output.

Sprintf()

  • sprintf() function is used to store formatted data as a string and to create strings as output using formatted data. int sprintf (char *string, const char *form, …);

Sample Code

#include <stdio.h>
int main()
{
    char str[100];
    sprintf((char*)str,"My name is %s,\n I am %d years old.","wikitechy",23);
    printf("Text is: %s\n",str);
    return 0;
}

Output

Text is: My name is wikitechy,
I am 23 years old.


View More Quick Examples


Related Searches to Printf and Sprintf in C - Printf and Sprintf in C Programming Language