#include <stdio.h>
#include <string.h>
#define MAX_NOTLAR 100
struct Not {
char ad[100];
char icerik[100];
};
struct Not notlar[MAX_NOTLAR];
int not_sayisi = 0;
void notlari_kaydet() {
FILE *dosya;
int i;
dosya = fopen("notlar.txt", "a+");
if (dosya == NULL) {
printf("Dosya açılamadı\n");
return;
}
for (i = 0; i < not_sayisi; i++) {
fprintf(dosya, "%s\n%s\n", notlar[i].ad, notlar[i].icerik);
}
fclose(dosya);
}
void notlari_yukle() {
FILE *dosya;
char ad[100];
char icerik[100];
dosya = fopen("notlar.txt", "r");
if (dosya == NULL) {
return;
}
not_sayisi = 0;
while (fscanf(dosya, "%99[^\n]\n%99[^\n]\n", ad, icerik) == 2) {
strcpy(notlar[not_sayisi].ad, ad);
strcpy(notlar[not_sayisi].icerik, icerik);
not_sayisi++;
}
fclose(dosya);
}
void not_adi_ekle(char *not_adi) {
if (not_sayisi == MAX_NOTLAR) {
printf("Not defteri dolu\n");
return;
}
strcpy(notlar[not_sayisi].ad, not_adi);
}
void not_ekle(char *note) {
if (not_sayisi == MAX_NOTLAR) {
printf("Not defteri dolu\n");
return;
}
strcpy(notlar[not_sayisi].icerik, note);
not_sayisi++;
notlari_kaydet();
}
void notlari_goruntule() {
int i;
notlari_yukle();
for (i = 0; i < not_sayisi; i++) {
printf("%d. %s: %s\n", i + 1, notlar[i].ad, notlar[i].icerik);
}
}