logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/sternflCode/p1.c

#include<stdio.h>

//count sequences where c==p

int main()  {
  int c;
  int p=-1;
  int count=0;
  FILE *f = fopen("message", "r");
  while ( (c=fgetc(f)) != EOF) {
    if (c==p)
      count++;
    p=c;
  }
  printf("%d\n", count);
}