Fix (Cexpr?struct1:struct2).member
[tinycc.git] / tests / tests2 / 28_strings.c
blob2db22986e8f6294aa5dff29fb5eb1b5c981db8a1
1 #include <stdio.h>
2 #include <string.h>
4 int main()
6 char a[10];
8 strcpy(a, "hello");
9 printf("%s\n", a);
11 strncpy(a, "gosh", 2);
12 printf("%s\n", a);
14 printf("%d\n", strcmp(a, "apple") > 0);
15 printf("%d\n", strcmp(a, "goere") > 0);
16 printf("%d\n", strcmp(a, "zebra") < 0);
18 printf("%d\n", strlen(a));
20 strcat(a, "!");
21 printf("%s\n", a);
23 printf("%d\n", strncmp(a, "apple", 2) > 0);
24 printf("%d\n", strncmp(a, "goere", 2) == 0);
25 printf("%d\n", strncmp(a, "goerg", 2) == 0);
26 printf("%d\n", strncmp(a, "zebra", 2) < 0);
28 printf("%s\n", strchr(a, 'o'));
29 printf("%s\n", strrchr(a, 'l'));
30 printf("%d\n", strrchr(a, 'x') == NULL);
32 memset(&a[1], 'r', 4);
33 printf("%s\n", a);
35 memcpy(&a[2], a, 2);
36 printf("%s\n", a);
38 printf("%d\n", memcmp(a, "apple", 4) > 0);
39 printf("%d\n", memcmp(a, "grgr", 4) == 0);
40 printf("%d\n", memcmp(a, "zebra", 4) < 0);
42 return 0;
45 /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/