Print how many times a sequence of characters appears in a string
Missed detection of EOF: getchar() returns an int with values in the range of unsigned char and the negative value of EOF.  Saving that result in a char loses distinctiveness should getchar() return EOF due to stdin becoming closed or input error.

//char ch;
//while ((ch = getchar()) != '#')
int ch;
while ((ch = getchar()) != '#' &amp;&amp; ch != EOF)

Why uint16_t?  The input stream can be excessively long, and certainly more than 65,535.  Suggest a wider type.  (Good that code uses an unsigned integer.)

// uint16_t count = 0;
unsigned long long  = 0;

Code could do this with 2 variables rather than 3.

int ch;
previous = EOF;

while ((ch = getchar()) != '#' &amp;&amp; ch != EOF) {
  if (previous == `e` &amp;&amp; ch == `i') {
    count++;
  }
  previous = ch;
}

Recommend {}

// if (last_ch == 'e' &amp;&amp; cur_ch == 'i')
//     count++;
if (last_ch == 'e' &amp;&amp; cur_ch == 'i') {
    count++;
}

Grammar: Code goes though work to print are vs. is yet does not make correct with ei's vs. ei.