this is a program to look into a word and see how many times a letter (input) is repeated
#include <stdio.h>
#include <string.h>
int main(){
int cont = 0;
char word[50], letter;
int i;
printf("enter the word: ");
scanf("%s", word);
printf("enter the letter you want to know how many times it repeats itself: ");
scanf("%c", &letter);
for (i=0; i < strlen(word); i++){
if (letter == word[i])
{
cont += 1;
}
}
printf("the letter you typed is repeated %d times", cont);
return 0;
}
my issue is when it comes to compiling it, it only allows me to put my first scanf(word) and not my second one (letter).
I expected the terminal to ask me what letter I want to search but instead I got this.
(base) erickpruneda@MacBook-Air-de-Erick C % cd "/Users/erickpruneda/Documents/Documentos - MacBook Air de Erick/developer/code for s
chool/C/" && gcc strings.c -o strings && "/Users/erickpruneda/Documents/Documentos - MacBook Air de Erick/developer/code for school/C
/"strings
enter the word: book
enter the letter you want to know how many times it repeats itself: the letter you typed is repeated 0 times%
as you can see, it didn't let me enter the letter. this was coded in VScode