Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int findSeq(){
- char charArray[] = {"0000110"};
- int pos = 0; //pos in array
- int found = 0;
- char curr;
- int flag = 1;
- while (flag != EOF){
- flag = scanf("%c%*c", &curr); //grab user's input
- //printf("Users input: %c\n", curr); //print user's input
- //printf("Array pos: %c\n", charArray[pos]); //print current position in array
- if(curr == charArray[pos]){
- pos++;
- } else{
- pos=0;
- }
- if (pos == 3){
- pos = 0;
- found++;
- }
- }
- return found;
- }
- int main(){
- printf("Found: %d\n", findSeq());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement