Character Array Strings
Character Array Strings
puts(str2); // C programming
return 0;
}
C strcmp()
#include <stdio.h>
#include <string.h>
int main() {
char str1[100] = "This is ", str2[] = "programiz.com";
// concatenates str1 and str2
// the resultant string is stored in str1.
strcat(str1, str2);
puts(str1);
puts(str2);
return 0;
}
strlwr() function in C
• The strlwr( ) function is a built-in function in C and is used to convert a given string into
lowercase.
• Syntax:
• char *strlwr(char *str); Parameter:
• str: This represents the given string which we want to convert into lowercase.
• Returns: It returns the modified string obtained after converting the characters of the
given string str to lowercase.
#include<stdio.h>
#include<string.h>
int main()
{
char str[ ] = "GEEKSFORGEEKS IS THE BEST";
// converting the given string into lowercase.
printf("%s\n",strlwr (str));
return 0;
}
strupr() function in c
// c program to demonstrate
// example of strupr() function.
#include<stdio.h>
#include<string.h>
int main()
{
char str[ ] = "geeksforgeeks is the best";
//converting the given string into uppercase.
printf("%s\n", strupr (str));
return 0;
}
C Reverse String: strrev()
#include<stdio.h>
#include <string.h>
int main(){
char str[20];
printf("Enter string: ");
gets(str);//reads string from console
printf("String is: %s",str);
printf("\nReverse String is: %s",strrev(str));
return 0;
}
strstr() in C
int main()
{
// Take any two strings
char s1[] = "GeeksforGeeks";
char s2[] = "for";
char* p;
}
int main()
{
// declare and initialize string
char str[] = "GeeksforGeeks";
// print string by passing string
// to a different function
printStr(str);
return 0;
}
#include<stdio.h>
void main ()
{
int myAge = 43; // An int variable
int* ptr = &myAge; // A pointer variable, with the name ptr, that stores the
address of myAge