Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- typedef struct aluno{
- char matr[10];
- char nome[30];
- float media;
- }Taluno;
- typedef struct novoaluno{
- char matr[10];
- char nome[30];
- float media;
- int faltas;
- }Tnovoaluno;
- int main(){
- int resp;
- int teste;
- FILE*arq;
- FILE*arq2;
- Taluno aux;
- Taluno AL;
- Tnovoaluno AL2;
- arq=fopen("turmaProgI.dat","wb");
- if(arq==NULL)
- printf("\nErro na criacao do arquivo!");
- else{
- do{
- printf("\nInforme o nome do aluno: ");
- fgets(AL.nome,29,stdin);fflush(stdin);
- printf("\nInforme a matricula de %s: ",AL.nome);
- fgets(AL.matr,9,stdin);fflush(stdin);
- printf("Informe a media de %s: ",AL.nome);
- scanf("%f",&AL.media);fflush(stdin);
- teste=fwrite(&AL,sizeof(AL),1,arq);
- if(teste==1)
- printf("Registro gravado com sucesso!");
- else{
- printf("Erro de gravacao!");
- break;
- }
- do{
- printf("Deseja criar outro Registro? ");
- resp=toupper(getchar());fflush(stdin);
- }while(resp!='S'&&resp!='N');
- }while(resp=='S');
- fclose(arq);
- }
- arq2=fopen("novoProgI.dat","wb");
- if(arq2==NULL)
- printf("\nErro na criacao do arquivo!");
- else{
- fread(&aux,sizeof(Taluno),1,arq);
- fwrite(&aux,sizeof(Taluno),1,arq2);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement