Run time check failure #2 Stack corrupted

Hi, Im starting to programming and I'm triying to do a Hangman Game in Spanish with words from a file.
I haven't used any pointer and I'm not sure which is the problem in my code.
It works good until the last line when it appears the Run time check failure,it says that "char letra" is corrupted. Char letra is the letter that user puts in.
Thanks in advance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main()
{typedef char array[50]; //Definimos el tipo cadenaCaracteres
	array palabras[20]; //Creamos un vector de cadenas
	int i, longitud, a, vidas = 5, fallo;
	char letra, jugando[20], adivinar[20];
	FILE *fp_read;
	fp_read = fopen("palabras.txt", "r");
	printf("Tienes %d vidas\n", vidas);
		printf("Dime una letra:\n");
		fflush(stdin);
		scanf("%c", &letra);
		fflush(stdin);
		getchar();
}
Last edited on
letra is a single char. You tell scanf to treat it as a string. Don't do that.
Thank you very much! Solved!
Topic archived. No new replies allowed.