RSS

Membaca file akses random secara sekuensial

18 Apr

contoh program:

 

#include <stdio.h>

struct clienData {

int acctNum;

char lastName[15];

char firstName[10];

float balance: };

void main() {

struct clientData client;

FILE *cfPtr;

 

if((cfPtr = fopen(“credit.dat”,”r”)) ==NULL)printf(“File tidak dapat dibuka.\n”);

else {

printf(“%-6s%-16s%-11s%10s\n”,”Acct”,”Last Name”,”first Name”,”Balance”);

while (!feof(cfPtr)) {

fread(&client, sizeof(struct clientData), 1, cfPtr);

if(client.AcctNum !=0)

printf(“%-6s%-16s%-11s%10s\n”, client.acctNum, client.lastName, client.firstName,client.Balance);

}

}

fclose(cfPtr);

}

 
Tinggalkan komentar

Ditulis oleh pada April 18, 2012 in algoritma dan pemrograman

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: