Explain in detail how strset (string handling function
works )pls explain it with an example.



Explain in detail how strset (string handling function works )pls explain it with an example...

Answer / lakshman

strnset - strset - Set Bytes in String

Syntax




#include <string.h>
char *strnset(char *string, int c, size_t n);
char *strset(char *string, int c);


Example:



#include <stdio.h>
#include <string.h>

int main(void)
{
char *str = "abcdefghi";

printf("This is the string: %s\n", str);
printf("This is the string after strnset: %s\n",
strnset(str, 'x', 4));
printf("This is the string after strset: %s\n",
strset(str, 'k'));
return 0;


/****************************************************************************
The output should be:

This is the string: abcdefghi
This is the string after strnset: xxxxefghi
This is the string after strset: kkkkkkkkk

****************************************************************************/
}

Is This Answer Correct ?    11 Yes 12 No

Post New Answer

More C Interview Questions

For what purpose null pointer used?

0 Answers  


different between overloading and overriding

3 Answers  


how to print "hai" in c?

13 Answers   TCS,


Are there constructors in c?

0 Answers  


code for quick sort?

0 Answers  






What is encapsulation?

2 Answers  


Why is structure padding done in c?

0 Answers  


Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?

0 Answers  


What is wrong with this program statement? void = 10;

0 Answers  


Tell me what is the purpose of 'register' keyword in c language?

0 Answers  


Explain why c is faster than c++?

0 Answers  


what is the return type of printf

3 Answers  


Categories