Mr-Fakoo
Decapat
- Katılım
- 11 Mayıs 2019
- Mesajlar
- 162
- Çözümler
- 4
C ile bir program yazıyorum # vaya + değil. Struct yapısı ile bir dosyaya veriyi kaydettim ama yazdığım diğer programda dosyadan veriyi okuyamadım, kullanıcıyı bulmuyor internetten araştırdım yapıyorum ama yine okumuyor.
Kayıt için kullandığım kod-->
Okuma için kullandığım kod-->
Kayıt için kullandığım kod-->
C:
#include<stdio.h>
#include<conio.h>
main()
{
struct ogrenci{
char adi[20],soyad[20],ders[10];
int no,vize,final,uyg;
};
struct ogrenci ogr;
FILE*dd;
char de;
dd=fopen("ogr.dat","a");
de='e';
while(1)
{
printf("Ogrenci Numarasi -->");
scanf("%d",&ogr.no);
printf("Adi -->");
scanf("%s",&ogr.adi);
printf("Soyadi -->");
scanf("%s",&ogr.soyad);
printf("Ogrenci Dersi -->");
scanf("%s",&ogr.ders);
printf("Uygulama Notu -->");
scanf("%d",&ogr.uyg);
printf("Vize -->");
scanf("%d",&ogr.vize);
printf("Final -->");
scanf("%d",&ogr.final);
fprintf(dd,"%d \t ADI:%s \t SOYADI:%s \t DERS:%s \t UYGULAMA:%d \t VIZE:%d \t FINAL:%d \t \n",
ogr.no,ogr.adi,ogr.soyad,ogr.ders,ogr.uyg,ogr.vize,ogr.final);
printf("\n---------------------------------\n");
printf("Devam etmek istiyormusunuz ?(e/h)");
de=getche();
if(de=='h') break;
printf("\n");
}
fclose(dd);
getch();
return 0;
}
Okuma için kullandığım kod-->
C:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
struct ogrenci.
{
char adi[20],soyad[20],ders[10];
int no,vize,final,uyg;
};
char ara[20],next;
int y,i;
int main ()
{
FILE *dd;
dd = fopen("ogr.dat","r" );
arama:i=2; y=0;
printf("\nARANAN KISININ NUMARASI..");
scanf("%d",&ara);
printf("No ADI SOYADI BOLUMU VIZE FINAL");
printf("\n-------------------------------------------\n");
struct ogrenci ogr;
while(!feof(dd)
{
while( fscanf(dd,"%d %s %s %s %d %d %d",&ogr.no,ogr.adi,ogr.soyad,ogr.ders,&ogr.uyg,&ogr.vize,&ogr.final))
{
if(ara==ogr.no)
{
i++;
printf("%d\t",ogr.no);
printf("%s\t",ogr.adi);
printf("%s\t",ogr.soyad);
printf("%s\t",ogr.ders);
printf("%d\t",ogr.uyg);
printf("%d\t",ogr.vize);
printf("%.d\n",ogr.final);
}
}
if(y==0)
{
printf("%d NUMARALI KAYIT BULUNAMADI..!",ara);
printf("TEKRAR KAYIT ARANACAK MI ? (E/H)..:");
next=getche();
if(next=='E'|| next=='e')
{goto arama;}
else.
break;
fclose(dd);
}
}
getch();
}