Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
JagoVB JagoVB is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 508
Rep Power: 14
JagoVB mempunyai hidup yang Normal
Default File

gan, mau tnya nih program ane ttg file, tiap di run, tuh bisa, ga eror, cuma 1, pengisian data nya itu loh, yg aneh



di bagian yg ane bold, itu kdg ga bsa

format notepad nya

K0001#10000#Sandal Gunung




Code:

/* Nama : Ibnu Vito Gunadi
Kelas : TI-C
NIM : 10110110099
*/

#include
#include
#include
#include

struct brg{
char kdbrg[6],nmbrg[25];
int harga;
};

struct jual{
int nota,qty,total;
char kdbrg[5];
};

void datbrg(struct brg datbar[]){
printf("1");
}

void inju(struct jual datju[]){
printf("2");
}

int main()
{
struct brg datbar[99];
struct jual datju[99];
char pilih;
int i=1;
FILE *brg,*jual;

brg = fopen("brg.txt","a+");
//jual = fopen("jual.txt","a+");

/*while(!feof(brg))
{
fscanf(brg,"%[^#]#%d#%s\n",datbar[i].kdbrg,datbar[i].harga,datbar[i].nmbrg);
i++;
}*/

while(!feof(brg))
{
fscanf(brg,"%[^#]#%[^#]#%[^\n]",&datbar[i].kdbrg,&datbar[i].harga,&datbar[i].nmbrg);
i++;
}

printf("%s\n",datbar[2].harga);


//printf("2");
printf("Pilih : \n1. Input Barang\n2. Input Penjualan\n3. List Barang\n4. List Penjualan\nx.Selesai\n");
scanf("%c",&pilih);
for( ; pilih != 'x' ; )
{switch(pilih)
{
case '1' : datbrg(datbar);

break;
case '2' : inju(datju);break;
case '3' : printf("3\n");break;
case '4' : printf("4\n");break;
}
fflush(stdin);
getche();
system("cls");
printf("Pilih : \n1. Input Barang\n2. Input Penjualan\n3. List Barang\n4. List Penjualan\nx.Selesai\n");
scanf("%c",&pilih);
}

fclose(brg);

getche();
return 0;

}





Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 09:06 PM.


no new posts