aboutsummaryrefslogtreecommitdiff
path: root/simple-C-programs/cc4e_ch5_exercise.c
blob: b3667b7b8446d9fb60fd63fd54470a806ca6adf5 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

#include <stdio.h>

void process(char *line) {

  // first function of the function;
  printf("\nString: %s\n", line);

  // second function of the function
  int count = 0;
  while (line[count] != '\0') {
    count++;
  }
  printf("Count=%d\n", count);

  // third function of the function
  if (count > 10) {
    printf("The tenth character is: %c", line[9]);
  }

  // fourth function of the function

  count = 0;
  while (line[count] != '\0') {
    if (line[count] == ' ') {
      line[count] = '-';
    }
    count++;
  }

  // fifth fucntion of the function
  printf("\nString: %s\n", line);
}

int main() {

  char input[1000];

  fgets(input, sizeof(input) - 1, stdin);

  process(input);

  return 0;
}