Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
534 B
2
Indexable
Never
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char str[100];
    int i = 0, times = 0;

    printf("Input a string of characters ending with '#': ");
    char ch = getchar();
    while(ch != '\n'){
        str[i] = ch;
        ch = getchar();
        i++;
    }

    for(int j = 0; j < str[j] != '#'; j++){
        if(str[j] == 'o' && str[j+1] == 'f'){
            times++;
        }
    }
    printf("The number of times that the sequence in:%d\n", times);

    return 0;
}