Last active
March 27, 2017 20:08
-
-
Save keremistan/af5a9c1e5f3a9960c764c64742abf725 to your computer and use it in GitHub Desktop.
fprintf() ve fscanf() fonksiyonlarının kullanımlarına birer örnek!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void yazma(); | |
void okuma(); | |
int main(void){ | |
// fprintf - fscanf | |
yazma(); | |
okuma(); | |
return 0; | |
} | |
void yazma(){ | |
FILE *fp = fopen("/Users/keremdede/Desktop/test.txt", "w"); | |
if(fp == NULL){ | |
printf("Dosya Acilamadi!\n"); | |
return; | |
} | |
char *isim = "Kerem"; | |
char *sehir = "Istanbul"; | |
fprintf(fp, "%s %s dogumlu\n", isim, sehir); | |
fclose(fp); | |
} | |
void okuma(){ | |
FILE *fr = fopen("/Users/keremdede/Desktop/test.txt", "r"); | |
if(fr == NULL){ | |
printf("Dosya Acilamadi!\n"); | |
return; | |
} | |
char kelimeler[3][10]; | |
fscanf(fr, "%s : %s %s", kelimeler[0], kelimeler[1], kelimeler[2]); | |
for (int i = 0; i < 3; ++i) { | |
printf("%d. kelime %s\n", i, kelimeler[i]); | |
} | |
fclose(fr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment