I'm trying to get the gets()
function to work on a given string. Everything else works properly up to this point.
char nads[100];
gets(nads);
printf("%s", nads);
The rest of the code follows, but I can't see why it would cause an issue.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <math.h>
void problema_1 (void);
void problema_2 (void);
int main()
{
setlocale(LC_ALL, "Portuguese_Brazil");
INICIO: printf("Para visualizar as respostas dos desafios, digite o número do mesmo : ");
int problema;
scanf("%i", &problema);
if (problema==1)
{
problema_1();
}
else if (problema==2)
{
problema_2();
}
else
{
printf("Escolha um valor válido e reinicie\n");
goto INICIO;
}
return 0;
}
void problema_1(void)
{
char nads[100];
gets(nads);
printf("%s", nads);
}
void problema_2(void)
{
printf("Resolução problema 2");
FILE *matriz;
matriz = fopen("matriz.txt", "r");
}