What is string explain any 5 functions with example?
C String Functions
No. | Function | Description |
---|---|---|
4) | strcmp(first_string, second_string) | compares the first string with second string. If both strings are same, it returns 0. |
5) | strrev(string) | returns reverse string. |
6) | strlwr(string) | returns string characters in lowercase. |
7) | strupr(string) | returns string characters in uppercase. |
How do you input a string give example?
Accepting string as the input
- #include
- void main ()
- {
- char s[20];
- printf(“Enter the string?” );
- scanf(“%s”,s);
- printf(“You entered %s”,s);
- }
What are the different string library functions in C write one with an example?
In this article, you’ll learn to manipulate strings in C using library functions such as gets(), puts, strlen() and more….More videos on YouTube.
Function | Work of Function |
---|---|
strcpy() | copies a string to another |
strcat() | concatenates(joins) two strings |
strcmp() | compares two strings |
strlwr() | converts string to lowercase |
What are the examples of string?
1. A string is any series of characters that are interpreted literally by a script. For example, “hello world” and “LKJH019283” are both examples of strings.
How do you write a program using string?
String Example in C
- #include
- #include
- int main(){
- char ch[11]={‘j’, ‘a’, ‘v’, ‘a’, ‘t’, ‘p’, ‘o’, ‘i’, ‘n’, ‘t’, ‘\0’};
- char ch2[11]=”javatpoint”;
- printf(“Char Array Value is: %s\n”, ch);
- printf(“String Literal Value is: %s\n”, ch2);
- return 0;
What are string functions explain various string functions?
String is an array of characters. We can perform such operations using the pre-defined functions of “string. h” header file. In order to use these string functions you must include string. h file in your C program.