Write a program that demonstrates the use of width and number of character specifier with %s conversion specifier in printf( ) when used with strings.

C Programming Language String in C Language (Article) String in C Language (Program)

747

Program:

#include <stdio.h>

int main()
{
  char str[50];

  printf("\n Enter a string:");
  scanf("%s",str);

  printf("\n %*.*s\n",2,3,str);

  return 0;

 }

Output:

 Enter a string:atnyla

 atn 

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.