String Function in C


The string.h header defines one variable type, one macro, and various functions for manipulating arrays of characters.

Source Code

#include<stdio.h>
#include<string.h>
 
int main()
{
    char c[20],a[20];
    char x[10]={'R','A','M','\0'};
    char y[10]={'K','U','M','A','R','\0'};
    printf("x : %s",x);
    printf("\nEnter The String : ");
    gets(c);
 
    printf("\nCompare   : %d ",strcmp(x,c));//String Compare
    printf("\nLength    : %d ",strlen(c));//String Length
    printf("\nReverse   : %s ",strrev(c));//String Reverse
    printf("\nUppercase : %s ",strupr(c));//String Upper
    printf("\nLowercase : %s ",strlwr(c));//String Lower
    printf("\nCopy      : %s ",strcpy(a,c));//String Copy
    strcat(x,y);
    printf("\nConcatenation : %s ",x);//String Concatenation
    return 0;
}
 
 
/*
char c[10];
printf("Enter The String : ");
//scanf("%s",c);
gets(c);
printf("%s",c);
*/
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes