-
Notifications
You must be signed in to change notification settings - Fork 0
/
masterupdate.c
31 lines (28 loc) · 960 Bytes
/
masterupdate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "headertoko.h"
int masterupdate() {
printf("=========================== INPUT/EDIT/ ==========================\n");
struct masterbarang data = {0, "", 0};
FILE *master;
master = fopen("masterbarang.dat", "rb+");
while(1) {
printf("Masukkan kode barang (0 untuk selesai)\n? ");
scanf("%d", &data.kode);
if (data.kode <= 0) {
break;
}
printf("Masukkan nama barang dan harga beli barang\n? ");
scanf("%s %d", data.nama, &data.hargabeli);
fseek(master, (data.kode - 1)*sizeof(struct masterbarang), SEEK_SET);
fwrite(&data, sizeof(struct masterbarang), 1, master);
}
printf("Master barang di-update.\nTekan enter untuk kembali ke menu awal ...\n");
_getch();
fclose(master);
}