-->
Showing posts with label string Formatting in C. Show all posts
Showing posts with label string Formatting in C. Show all posts

Wednesday, June 25, 2025

string Formatting in C Programming | Format Specifier Examples with Code

 

C program collection


C program to print the number in the formatted form

//string formatting in c program

#include<stdio.h>

int main()

{

char name[]="Radhekrishna";

char name1[]="krishna";

printf("name=%s\n",name);

printf("[%20s]-right alignment\n",name);

printf("[%-20s]-left alignment\n",name);

printf("[%.3s]-only three characters.\n",name1);

printf("[%s]-all characters\n",name1);

return 0;


}


C program to format the string