#include <stdio.h>
void main()
{
char n[10];
int i, j;
for (i=0; j<10; j++)
{
printf("\n Enter the character %d",i);
fflush(stdin);
scanf("%c", &n[i]);
}
for(i=0;j<10;j++)
printf("%c", n[i]);
}
Functions | Description |
---|---|
Strlen | It finds the length of the string. |
Strlwr | It converts the string into lower case. |
Strupr | It converts the string into upper case. |
Strcat | It appends one string at the end of another. |
strncat | It appends the first n character of the string at the end of another. |
strcpy | It copies a string into another. |
strncpy | It copies the first n characters of one string into another. |
strcmp | It compares two strings. |
strncmp | It compares the first n characters of two strings. |
Write a program to demonstrate string function of length, copy and concatenation.
#include <stdio.h>
#include <string.h>
void main ()
{
char s1[12] = "Tutorial";
char s2[12] = "Ride";
char s3[12];
int l ;
/* string copy */
strcpy(s3, s1);
printf("strcpy( s3, s1) : %s\n", s3 );
/* string concatenation */
strcat( s1, s2);
printf("strcat( s1, s2): %s\n", s1 );
/* string length */
l = strlen(s1);
printf("strlen(s1) : %d\n", l );
}