diff options
Diffstat (limited to '17_read_arr2/test.c')
-rw-r--r-- | 17_read_arr2/test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/17_read_arr2/test.c b/17_read_arr2/test.c new file mode 100644 index 0000000..e0b30b0 --- /dev/null +++ b/17_read_arr2/test.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define NSTRS 3 +int main(void) { + const char * strs[NSTRS] = {"apple", "bannana", "carrot"}; + + for (int i = 0; i < NSTRS; i++) { + const char * a = strchr(strs[i], 'a'); + a++; + printf("%c\n", *a); + printf("%c\n", a[2]); + a = strstr(strs[i], "nana"); + if (a != NULL) { + printf("%s has %s %ld characters into it!\n", strs[i], a, a - strs[i]); + } + } + const char * ptr = strs[2]; + while (*ptr != '\0') { + char x = *ptr + 3; + printf("%c", x); + ptr++; + } + printf("\n"); + return EXIT_SUCCESS; +} |