strset() string handling functions - C-Tutorial

Latest

Friday, 7 October 2016

strset() string handling functions

C – strset() function


  • ·         strset( ) function sets all the characters in a string to given character.
·         syntax: char *strset(char *string, int c);

  • ·         strset( ) function is non standard function which may not available in standard library in C.
  • ·         In this program, all characters of the string “Test String” is set to “#” using strset( ) function and output is displayed as “###########”.


#include<stdio.h>
#include<string.h>
 main()
{
   char str[20] = "Test String";
   printf("Original string is : %s", str);
   printf("Test string after strset() : %s",strset(str,'#'));
   printf("After string set: %s",str);
}

No comments:

Post a Comment