Advertisement
akevintg

FILE handling in C

Dec 10th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main(){
  4.     char title[10][100];
  5.     char Speaker[10][100];
  6.     char teks[10][100000];
  7.     int i=0;
  8.     int hitung=0;
  9.     FILE *penampung;
  10.     penampung=fopen("BeeFest.txt", "r");
  11.     if(penampung==NULL)
  12.         printf("File tidak ditemukan");
  13.     else{
  14.         while(!feof(penampung)){
  15.             fscanf(penampung, "%[^;];%[^;];%[^;];",title[hitung],Speaker[hitung],teks[hitung]);
  16.             hitung++;
  17.         }
  18.     }
  19.     for(i=0;i<hitung;i++){
  20.         printf("Title: %s\n",title[i]);
  21.         printf("Speaker: %s\n",Speaker[i]);
  22.         printf("Teks: %s\n\n",teks[i]);
  23.     }
  24.     fclose(penampung);
  25. }
  26.  
  27. // file BeeFest.txt can be downloaded from : https://www.dropbox.com/s/pjv7mm562qw6v3c/BeeFest.txt?dl=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement