Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. #define MAXLINE 1000
  3. /*#define YES 1
  4. #define NO 0 */
  5.  
  6.  
  7. char process_line(char line[]);
  8. main(void)
  9. {
  10. char line[MAXLINE] ;
  11. gets(line);
  12. process_line(line);
  13. /*puts(line);*/
  14. system("pause");
  15. return 0;
  16. }
  17.  
  18. char process_line(char buffer[])
  19. {
  20. char c;
  21. char prev_c;
  22. char *ptr;
  23.  
  24. int counter;
  25.  
  26. ptr = buffer;
  27. prev_c =' ';
  28. c = *ptr;
  29. counter = 0;
  30.  
  31.  
  32. while (c != '\0')
  33. {
  34. if ((prev_c == 'c') && (c == 'd')) counter++;
  35. prev_c = *ptr;
  36. ptr++;
  37. c = *ptr;
  38. }
  39. printf("counter = %i\n", counter);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement