Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct record
- {
- int id_number;
- int age;
- int height;
- int weight;
- float salary;
- }record;
- int main ()
- {
- FILE *fp;
- record *registro = NULL;
- int count = 1, option, i;
- while (count != 0)
- {
- puts("****************************");
- puts("1 - Inserir registro.");
- puts("2 - Pequisar registro.");
- puts("3 - Sair.");
- puts("****************************");
- scanf("%d", &option);
- if(option == 1)
- {
- puts("Insira o ID:");
- scanf("%d", ®istro[i].id_number);
- puts("- Insira a idade:");
- scanf("%d", ®istro[i].age);
- puts("- Insira o tamanho:");
- scanf("%d", ®istro[i].height);
- puts("- Insira o peso:");
- scanf("%d", ®istro[i].weight);
- puts("- Insira o salario:");
- scanf("%d", ®istro[i].salary);
- fp = fopen("C:/Users/alunoinf/Desktop/test.bin", "wb");
- fwrite (®istro, sizeof(registro), 1, fp);
- }
- else if(option == 2)
- {
- }
- else if (option == 3)
- {
- count = 0;
- }
- else
- {
- puts("Opcao invalida.");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement