![]() |
Structer’dan FILE’a Veri Yazdirma Program normal array olmayan pointer kullanmayan hatta malloc bile kullanmayan bir sturucter a kullanıcıdan veri yazip daha sonra structerdaki veriyi aynen binary modda açılmış bir dosyaya aktaran bir programcik. #include struct data { int id; char name[20]; double price; int quantity; }product; void main() { FILE *ptr; ptr=fopen(“data.txt”,”wb+”); product.id=1; char blank[2]; while(product.id!=0) { printf(” Enter the product name : “); gets(product.name); printf(” Enter price : “); scanf(“%lf”,&product.price); printf(” Enter Quantity : “); scanf(“%d”,&product.quantity); printf(“Please Enter product id btw 0-100 : “); scanf(“%d”,&product.id); gets(blank); fwrite(&product,sizeof(struct data),1,ptr); } rewind(ptr); fread( &product, sizeof( struct data ), 1, ptr ); while ( !feof( ptr ) ) { fread( &product, sizeof( struct data ), 1, ptr ); printf( ” %d %s %lf %d “, product.id,product.name,product.price,product.quan tity ); } fclose(ptr); } |
| Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 10:55. |
Powered by vBulletin® Version 3.8.9 Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Site kurucuları: Damla ve Meltem