Example on Strings
#include <stdio.h>
#include <string.h>
main()
{
char s[] = "We study";
char t[] = "uoga uoga";
char v[15] = "did";
printf("%d\n", strlen(s));
printf("%d\n", strcmp(s,t));
printf("%s\n", strcpy(s,v));
printf("%s\t%s\n", s, v);
printf("%s\n", strcat(v, t));
printf("%s\n", strstr(t, "og"));
}
The program prints:
8
-30
did
did did
diduoga uoga
oga uoga
This is program
ex5.c
Previous slide
Next slide
Back to first slide
View graphic version