// ---------------------------------------------------------- #include struct buying_item { char name[16]; int price; int kind; } ; void input_buying_item(struct buying_item *item) { printf("Name?: "); scanf("%s",&item->name); printf("Price?: "); scanf("%d",&item->price); printf("Kind? (0:f,1:c,2:o): "); scanf("%d",&item->kind); } void print_kind_buying_item(int kind) { switch(kind){ case 0: printf("Food"); break; case 1: printf("Clothing"); break; case 2: printf("Other"); break; } printf("\n"); } void output_buying_item(struct buying_item item) { printf("Name : %s\n",item.name); printf("Price: %d\n",item.price); printf("Kind : "); print_kind_buying_item(item.kind); } void output_buying_item2(struct buying_item item) { printf("Name : %s\n",item.name); printf("Price: %d\n",item.price); } int total_price_biying_item(struct buying_item *item,int num,int kind) { int i; int total=0; for(i=0;i #include #include #include #include void main() { int fd,re; char fname[128]; char ch; // int i; printf("Input Filename: "); gets(fname); fd=open(fname,O_RDONLY); if(fd== -1){ printf("%s No such file\n"); return; } while(1){ re=read(fd,&ch,1); if(re==0) break; printf("%c",ch); } close(fd); } // ---------------------------------------------------------- #include #include #include #include #include void main() { int fd,re; char fname[128]; char ch; printf("Input Filename: "); gets(fname); fd=open(fname,O_WRONLY); if(fd== -1){ printf("%s No such file\n"); return; } while(1){ ch=getchar(); if(ch==EOF) break; re=write(fd,&ch,1); } close(fd); }