2
Hi, I’d like to understand why my code doesn’t work. I’m trying to develop a forcible application and I can’t get the typed letter to be compared to the letter that’s in the vector, which I’m doing wrong?
Follows the code:
#include<stdio.h>
#include<locale.h>
#include<time.h>
#include<stdlib.h>
#include<string.h>
int main (){
int i,len_palavra,exec=1,back;
char lacuna[20]="_";
char letra[20];
char palavra[4]="arroz";
setlocale(LC_ALL,"PORTUGUESE");
len_palavra = strlen(palavra);
for(i=1;i<=len_palavra;i++)
lacuna[i]='_';
while (exec == 1){
system("cls");
printf("\t\t%s\n",lacuna);
printf("\nDigite uma letra: ");
gets(letra);
for(i=0;i<len_palavra;i++){
if (letra[0] == palavra[i])
lacuna[i] == letra[0];
}
}
return 0;
}
We can start here: char word[4]="rice"; you are trying to harvest 5 values in a vector with size 4
– Dev