string functions
#include <stdio.h>
#include <string.h> //string functions library
int main()
{
char s1[]="harish"; //string1
char s2[]="shiva"; //string2
char s3[10];
//puts(strcat(s1,s2)); //concatenation
printf("length of s1:%d\n",strlen(s2)); //give length of string
printf("the reversed string of s1: ");
puts(strrev(s1)); //reverse the string
//s3=strcat(s1,s2); //you canot do like this
strcpy(s3,strcat(s1,s2)); //copy value in another variable
printf("s3 copied from s1 and s2:");
puts(s3);
return 0;
}
Comments
Post a Comment