logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/sternflCode/popCount.c

#include<stdio.h>

int main() {
 int c; 
 int p1=-1;
 int p2=-1;
 int count=0;
 FILE *f = fopen("myDiary", "r");
 while ( (c= getc(f))!= EOF) {
   if (p2=='p' && p1=='o' && c=='p')
     count++;
   p2 = p1;
   p1 = c;
 }
 printf("%d\n", count);

}