I'm trying to solve a college exercise, where the statement asks me to receive a record, with two fields as input data. One vector field to store name and another to store enrollment. I should also declare a pointer to the heterogeneous data structure, and use this pointer when reading data and printing the data on the screen.
My code does not show an error in Visual Studio, but when you open the command prompt it generates the error message:
Followmycode:
#include<stdlib.h>#include<stdio.h>#include<conio.h>//ProgramaPrincipalstructcadastro{//Declaraçãodastructparaarmazenamentoderegistrocom2camposcharnome[40];intru;};structcadastroaluno,*pont1;//variavelalunoreferenciandoastructintmain(){//Titulodoprogramaprintf("---------Cadastro de aluno----------\n");
printf("\n");
//Entrada de informações pelo usuário
printf("Digite seu nome: ");
fflush(stdin);//Limpa dados armazenados na memória
fgets((*pont1).nome, 40, stdin);//Referencia onde na struct deve ser armazenada a informação
printf("\n");
printf("Digite seu RU: ");
scanf_s("%d", (*pont1).ru);
//Print de dados informados pelo usuário
printf("\n");
printf("---------Dados Informados-----------\n");
printf("\n");
printf("O nome digitado foi: %s\n", (*pont1).nome);
printf("\n");
printf("O RU digitado foi: %d\n", (*pont1).ru);
printf("\n");
//Fim do programa
system("pause");
return 0;
}
In all places I've researched, I've seen the use of pointers to pre-defined values within the code, however, I'm trying to make the same function run with the information input by the user.
Can anyone help me?