Good afternoon,
Currently studying Language C and I am faced with a situation that has stuck in the progress of studies, I have made a structure that receives registration and address. The compiler does not report errors, but when it behaves strangely, not allowing all data to be received, the expected output on each line should be:
Name->
Age- >
Street- >
Where each line points to the data to be filled after typing and give enter.The error occurs after informing age:
Name-> Jeferson
Age- > 35
Street- >
In the same line as Street- strong>. Follow the code below, and I appreciate any help you may have.
#include<stdio.h>
#include<stdlib.h>
struct endereco{
char rua[50];
int numero;
};
struct cadastro{
char nome[50];
int idade;
struct endereco ender;
};
int main(int argc, char const *argv[])
{
struct cadastro c;
//Lê do teclado uma string e armazena no campo nome
printf("Nome-> ");
gets(c.nome);
//Lê do teclado um valor inteiro e armazena no campo idade
printf("Idade-> ");
scanf("%d",&c.idade);
//Lê do teclado uma string
//e armazena no campo rua da variavel ender
printf("Rua-> \n ");
gets(c.ender.rua);
//Lê do teclado um valor inteiro
//e armazena no campo numero da variavel ender
printf("Numero-> ");
scanf("%d",&c.ender.numero);
system("pause");
return 0;
}