158. Understanding predefined string functions.
#include<stdio.h>
#include<string.h>
int
u1,u2,u3,ch,ch1;
void
main()
{
char s1[]="Chinmay";
char s2[]="Vector";
char s3[]="India";
u1=strlen(s1);
printf("Length = %d\n",u1);
char s4[]="Chinmay";
char s5[]="Vector";
char s6[]="India";
strcpy(s4,s5);
printf("%s\n",s4);
char s7[]="Chinmay";
char s8[]="Vector";
char s9[]="India";
strncpy(s7,s8,2);
printf("%s\n",s7);
char s10[20]="Chinmay";
char s11[]="Vector";
char s12[]="India";
strcat(s10,s11);
printf("%s\n",s10);
char s13[]="Chinmay";
char s14[]="Vector";
char s15[]="India";
strncat(s13,s14,5);
printf("%s\n",s13);
char s16[]="Chinmay";
char s17[]="CHinmay";
char s18[]="India";
u2=strcmp(s16,s17);
printf("%d\n",u2);
char s19[]="Chinmay";
char s20[]="ChInmay";
char s21[]="India";
u3=strncmp(s19,s20,3);
printf("%d\n",u3);
char s22[]="Chinmay";
char ch = 'n';
printf("%s\n",strchr(s22,ch));
char s23[]="Cnhinmay";
char ch1 = 'n';
printf("%s\n",strrchr(s23,ch1));
char s24[]="Chinmay";
char s25[] = "nm";
printf("%s\n",strstr(s24,s25));
}
Comments
Post a Comment