I'm doing a game of Hangman in C and until now I have the count of the letters depending on the word to guess that the user enters, I already have a condition that tells me that if the letter that you enter is equal to any of the positions of the word then I will do a certain action and that's where my question comes in, how can I print the letters that fit within my lines, and how can I subtract the attempts that it has if it does not hit the letter?
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
int x,y,r,tamano,a;
char palabra[100],palabra2[100];
char letra;
int intentos=5;
printf ("***********AHORCADO*************\n");
printf ("Ingrese la palabra a adivinar:\n");
fflush(stdin);
gets(palabra);
system ("cls");
tamano=strlen(palabra);
printf("\n\n");
for (x=0;x<tamano;x++)
{
palabra2[x]=95;
}
for (x=0;x<tamano;x++)
{
printf (" %c",palabra2[x]);
}
printf ("\nIntentos: %d",intentos);
printf ("\n");
printf ("Ingrese una letra: ");
fflush(stdin);
scanf ("%c",&letra);
for (x=0;x<tamano;x++)
{
if (letra==palabra[x])
{
palabra2[x]=palabra[x];
}
else
intentos--;
}
}