Dosyalama - Kayıt-Listeleme-Arama-Düzenleme-Silme [C]

ALpMontana

КЯaL´da TaNıMaM КuяaL´da
Katılım
28 May 2006
Mesajlar
6,644
Reaction score
0
Puanları
0
Yaş
38
Konum
Eski Açık [ALiSamiYEN]
Basit bir öğrenci takip programı

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h>

struct ogrenci {
char adsoy[30];
char k; //kontrol degiskeni
char tel[15],adres[40],sehir[15],num[10];
}ogrkay;

FILE *dosya;
char cev;
int i,kaysay,say;
char c,ara[10];

void giris()
{
clrscr();
dosya=fopen("kayit.dat","a");
printf("OGRENCI NUMARASI ...:");gets(ogrkay.num);
printf("AD VE SOYAD ...:");gets(ogrkay.adsoy);
printf("ADRES ...:");gets(ogrkay.adres);
printf("SEHIR ...:");gets(ogrkay.sehir);
printf("TELEFON NUMARASI ...:");gets(ogrkay.tel);
printf("GIRILEN BILGILER DOGRU MU ?... E/H");
cev=getch();
if (cev=='E'|| cev=='e') { ogrkay.k='*';
fseek(dosya,filelength(fileno(dosya)),SEEK_SET);
fwrite(&ogrkay,sizeof(struct ogrenci),1,dosya);
flushall();
}
}

void baslik()
{ clrscr();
printf("%-10s%-20s%-25s%-10s%-10s\n\n","NUMARA","AD SOYAD","ADRES","SEHIR","TELEFON");
say=0;
}

void listele()
{ baslik();
kaysay=filelength(fileno(dosya))/sizeof(struct ogrenci);
for (i=0 ;i<kaysay;i++) {
fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET);
fread(&ogrkay,sizeof(struct ogrenci),1,dosya);
if (ogrkay.k=='*') {
say=say+1;
printf("%-10s",ogrkay.num);
printf("%-20s",ogrkay.adsoy);
printf("%-25s",ogrkay.adres);
printf("%-10s",ogrkay.sehir);
printf("%-10s\n",ogrkay.tel);
if (say==20) { printf("BIR SONRAKI SAYFA ICIN BIR TUSA BASIN...");
getch(); baslik();
}
}
}
printf("\n\n LISTELENECEK KAYITLAR SONA ERDI...");
getch();
}

int arama ()
{
clrscr();
printf("ARAMAK ISTEDIGINIZ OGRENCI NUMRASI ...:");gets(ara);
flushall();
for(i=0 ;i<kaysay;i++) {
fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET);
fread(&ogrkay,sizeof(struct ogrenci),1,dosya);
if (strcmp(ara,ogrkay.num)==0 && ogrkay.k=='*') {
clrscr();
printf("OGRENCI NUMARASI ...:%s\n",ogrkay.num);
printf("AD VE SOYAD ...:%s\n",ogrkay.adsoy);
printf("ADRES ...:%s\n",ogrkay.adres);
printf("SEHIR ...:%s\n",ogrkay.sehir);
printf("TELEFON NUMARASI ....:%s\n",ogrkay.tel);
printf("\nCIKIS YAPMAK ICIN LUTFEN BIR TUSA BASINIZ...");
getch(); return 0;
}
}
printf("ARANAN KAYIT BULUNAMADI...\n");
getch();
return 0;
}


int silme (void)
{
clrscr();
printf("SILINECEK OGRECI NUMARASINI GIRIN...:");gets(ara);
kaysay=filelength(fileno(dosya))/sizeof(struct ogrenci);
for (i=0 ;i<kaysay;i++) {
fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET);
fread(&ogrkay,sizeof(struct ogrenci),1,dosya);
if (strcmp(ara,ogrkay.num)==0 && ogrkay.k=='*') {
clrscr();
printf("OGRENCI NUMARASI ...:%s\n",ogrkay.num);
printf("AD VE SOYAD ...:%s\n",ogrkay.adsoy);
printf("ADRES ...:%s\n",ogrkay.adres);
printf("SEHIR ...:%s\n",ogrkay.sehir);
printf("TELEFON NUMARASI ...:%s\n",ogrkay.tel);
printf("\n SILME ISLEMINI GERCEKLESTIRMEK ISTIYOR MUSUNUZ?... E/H");
cev=getch();
if (cev=='E' || cev=='e'){
ogrkay.k='s';
fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET);
fwrite(&ogrkay,sizeof(struct ogrenci),1,dosya);
flushall();
printf("\n KAYIT SILME ISLEMI BASARIYLA GERÇEKLESTIRILDI !");getch();
return 0;
}
}
}
printf("SILINECEK KAYIT BULUNAMADI...\n");
getch();
return 0;
}



int duzelt( void)
{
clrscr();
printf("DUZELTME ISLEMI YAPILACAK OGRENCI NUMARASI...:");gets(ara);
kaysay=filelength(fileno(dosya))/sizeof(struct ogrenci);
for (i=0 ;i<kaysay;i++) {
fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET);
fread(&ogrkay,sizeof(struct ogrenci),1,dosya);
if (strcmp(ara,ogrkay.num)==0 && ogrkay.k=='*') {
do {
clrscr();
printf("1-OGRENCI NUMARASI ...:%s\n",ogrkay.num);
printf("2-AD VE SOYAD ...:%s\n",ogrkay.adsoy);
printf("3-ADRES ... :%s\n",ogrkay.adres);
printf("4-SEHIR ...:%s\n",ogrkay.sehir);
printf("5-TELEFON NUMARASI ...:%s\n",ogrkay.tel);
printf("6-KAYIT ÇIKIS ...\n");

printf("seçiminiz (1-6):");
cev=getch();
printf("\n");
switch (cev) {
case '1': printf("YENI OGRENCI NUMARASI ...:");gets(ogrkay.num);break;
case '2': printf("YENI AD VE SOYAD ...:");gets(ogrkay.adsoy);break;
case '3': printf("YENI ADRES ...:");gets(ogrkay.adres);break;
case '4': printf("YENI SEHIR ...:");gets(ogrkay.sehir);break;
case '5': printf("YENI TELEFON NUMARASI ...:");gets(ogrkay.tel);break;
}
}while (cev!='6');
fseek(dosya,i*sizeof(struct ogrenci),SEEK_SET);
fwrite(&ogrkay,sizeof(struct ogrenci),1,dosya);
flushall();
printf("\n KAYIT DUZELTME ISLEMI BASARIYLA GERCEKLESTIRILDI !");getch();
return 0;
}
}
printf("DUZELTILECEK KAYIT BULUNAMADI...\n");
getch();
return 0;
}


void main()
{
dosya=fopen("OGRENCI.DAT","r+b");
if (dosya==NULL) {
dosya=fopen("OGRENCI.DAT","w+b");
}
textbackground(8);textcolor(2);
do {
clrscr();
gotoxy(28,15);printf("<------------------------------->");
gotoxy(28,17);printf("* 1-BILGI GIRISI * ");
gotoxy(28,19);printf("* 2-BILGI ARAMA * ");
gotoxy(28,21);printf("* 3-BILGI LISTELEME * ");
gotoxy(28,23);printf("* 4-BILGI SILME * ");
gotoxy(28,25);printf("* 5-BILGI DUZELTME * ");
gotoxy(28,27);printf("* 6-PROGRAMI SONLANDIR * ");
gotoxy(28,29);printf("<------------------------------->");
gotoxy(3,50);printf("HAZIRLAYAN...:Kaan DURAN");
gotoxy(52,50);printf("SeCiminiz......... (1-6)");
c=getch();
if (c=='1') giris();
if (c=='2') arama();
if (c=='3') listele();
if (c=='4') silme();
if (c=='5') duzelt();
}while (c!='6');
fclose(dosya);
}
 
Bunu nereye yazıp program hakkına geliyor bilgi ltf tşk
 
bu programa derslerı,dersın olan sınıfları gıbı bazı seyler eklenebılırmı??hanı bana yardım amaclı...elıne saglık
 
tam olarak böyle bir programa ihtiyacım var ama bunun uygulamasını nasıl yapıcaz aceba? ya da yapan varsa direk uygulamayı koyabilir misiniz?
 
Geri
Üst