C Printf Format Specifiers Guide

In C language, string format can be set using the printf function, commonly used formats include:

  1. %s: used for displaying string
  2. %c: used to output characters.
  3. %d: used to print integers
  4. %f: used to output a floating-point number.
  5. %x: Used to display a hexadecimal number.
  6. %p: used to output the address of a pointer.

For example, you can format the output of a string and an integer like this:

char str[] = "Hello";
int num = 100;
printf("%s %d\n", str, num);

You can choose the appropriate format to output different types of data as needed.

bannerAds