summaryrefslogtreecommitdiff
path: root/17_read_arr2/test.c
blob: e0b30b0413d586daac461763769efd370f0a1b16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}