From a90038c80eb06134c1de7bc6715d23a8b72a7196 Mon Sep 17 00:00:00 2001 From: Win Date: Thu, 19 Sep 2024 13:36:17 +0700 Subject: [PATCH] added file error handling --- #vendorInfo# | Bin 0 -> 17811 bytes #vendorInfo.c# | 437 +++++++++++++++++++++++++++++++++++++++++++++++ vendor2.data | 1 + vendorInfo | Bin 17808 -> 17904 bytes vendorInfo.c | 10 +- vendorsmall.data | 1 + 6 files changed, 446 insertions(+), 3 deletions(-) create mode 100755 #vendorInfo# create mode 100644 #vendorInfo.c# diff --git a/#vendorInfo# b/#vendorInfo# new file mode 100755 index 0000000000000000000000000000000000000000..6b3e96921848fbe16fb6034b50a9ebf5e40f8269 GIT binary patch literal 17811 zcmeHP3vg4{nLZK_90Hbkr6lBWLm&eU7PcWgoP=Bhg6o8bF^|wks$5&wSVa$4x&k{5 zEm=bsMR7uQ@|rf?VRy4B-RBw3DTsbl2M<8EH&YHzlo`&}hH^ zJj9id98YJrGrQyC(f!Z={f~3bf6lr0+{f|kO$}f7tzYYQxtL0BwvrLoF;(Y~I5KwV zZq7<sZRY1n$r*jEWkyG@XTL=`bkb2`l$!->9IMoa24V+_4QB^~tWOq5~ zGArovs|Bkls}elfO`xpgS(Q#4c%73cD>-3`D!qJpnvgS17a2)s$jT_{w4>MzR}1yw zyM>*i-;;3}CM8O;UIY_V;Uy4srCvbK%0MWp;z`w@-*Oqx<>Q2%qJq2JPsMhf(ymk5 zDY^zeDJe>2P}=gY9r#nqYm#u5A71mVm2aOS9cl;pBpphmFRRRX zlBpjDMtPVGy=f(M=as>!^iulM%it5s;55xj`Po|ruP=jll))($rTp(NgEy4H_msiE z4_w2qIPC;bs@#ob@KhOmNg13@Bc=Q|mcgTCaIFl^+ICuYoW<=}YeyIBNQiudn6{W@ zF{?9Z6WrQv#z@PK?qY4x4l6=T2n6O_X4=sp3!9-(w3Ye&m_@DrxNXL4f7lF0m>ms8 z_gL`I5er7_Hr8fap%80p4MpP?FFf4A+TxbAi;*Qwx20^|`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vKOpVrO98dfg`cul z&jEtKNLAUZ=NT2Uz~hiP6ZvqauYjRv2g+VOFE}mj=|gNvs{Tq((XT;9&mt7Bo=2#C z<~7_}^pUgv5@tQfP)wD*dj2t=8jPguRr$s3e-=7qzlxNR)bo@b(tbcTnC$79OR@dm z03#LUKYu;OQi_s#&Lp@i$ItT+IPEogJ=df?e|M{lK_#50-zlAW#}Rs(kg_OZ`6ux__V~hhu*Hsc~=-GE!0YYTxg4;WK{WzUW*KsU2M;4h5ja`DE%l_(Rs+Iz9E&NfX+3W>NsI*l%im- zm_H;|V_&Lp^4wy<9h5gjG#%-_LB(C2zpn +#include +#include +#include + +#define MAX_VENDORS 20 +#define MAX_FILENAME_LENGTH 4096 + +/* STRUCTURES */ +typedef struct vendor +{ + char vendor_name[20]; + char merchandise[15]; + int inventory_count; + int item_price_baht; + int revenue; + int duplicate; +} vendor; + +// Return type for search function +typedef struct search_r +{ + int status; + int item_id; +} search_r; + +// Return type for purchase function +typedef struct purchase_r +{ + int status; + char vendor_name[20]; + int price_owe_baht; +} purchase_r; + +vendor vendors[MAX_VENDORS]; + +/* FUNCTION DECLARATION */ +int getstr(char str[], size_t n); +char *strnlower(char *s, size_t n); + +search_r search +( + char query[], + vendor vendors[MAX_VENDORS], + int total_vendors +); + +purchase_r purchase +( + int item_id, + int amount, + vendor vendors[MAX_VENDORS] +); + +int check_vendors(vendor vendors[MAX_VENDORS], int total_vendors); + +int main() +{ + char file_name[MAX_FILENAME_LENGTH]; + printf("Enter name of input file: "); + getstr(file_name, MAX_FILENAME_LENGTH); + + FILE *fp; + if ((fp = fopen(file_name, "r")) == NULL) + { + printf("%s cannot be opened.\n", file_name); + exit(EXIT_FAILURE); + } + + // Calculate the file size + fseek(fp, 0, SEEK_END); + unsigned long file_size = ftell(fp); + fseek(fp, 0, SEEK_SET); + + // Dynamically allocate buffer for file content + char *file_buffer = (char *) malloc(file_size); + int index = 0; + + // Reading the file with fgets and formatting them using strtok + while ((fgets(file_buffer, 50, fp) != NULL) && (index <= MAX_VENDORS - 1)) + { + char *token = strtok(file_buffer, " "); + strncpy(vendors[index].vendor_name, token, strlen(token) + 1); + + token = strtok(NULL, " "); + strncpy(vendors[index].merchandise, token, strlen(token) + 1); + + token = strtok(NULL, " "); + vendors[index].inventory_count = atoi(token); + + token = strtok(NULL, " "); + vendors[index].item_price_baht = atoi(token); + + index++; + } + + if (ferror(fp)) + { + printf(""); + } + + int total_vendors = index; + printf("\n>>> Read %d vendors from file %s\n", total_vendors, file_name); + + // Print out each vendor's info - excluding duplicates. + for (int i = 0; i <= (total_vendors - 1); i++) + { + /* + This is similar to a linear search algorithm + i = the current item + j = the item next to i + + i is being compared to j: + - if i == j then mark both i and j as duplicates + - if not, move on to the next two items + */ + for (int j = i + 1; j < total_vendors; j++) + { + if ((strcmp(vendors[i].merchandise, vendors[j].merchandise)) == 0) + { + vendors[j].duplicate = 1; + } + + if ((strcmp(vendors[i].vendor_name, vendors[j].vendor_name)) == 0) + { + vendors[j].duplicate = 1; + } + } + + if (vendors[i].duplicate == 0) + { + char vendor_info[200]; + sprintf(vendor_info, "%s sells %s for %d each", + vendors[i].vendor_name, + vendors[i].merchandise, + vendors[i].item_price_baht + ); + + char vendor_stock[50]; + sprintf(vendor_stock, "Inventory %d items", + vendors[i].inventory_count + ); + + printf("%-50s %s\n", vendor_info, vendor_stock); + } + else + { + printf("\e[31m%s\e[m\n", "Duplicate record detected!"); + } + } + + printf("\n"); + + while (1) + { + if(check_vendors(vendors, total_vendors) == 0) + { + break; + }; + + char user_query[100]; + printf("What do you want to buy? (DONE to end) "); + getstr(user_query, 100); + + if ( + (strcmp(user_query, "DONE") == 0) || + (strcmp(user_query, "done") == 0) + ) + { + break; + } + + if (strcmp(user_query, "") == 0) + { + printf("Please enter an item name\n"); + } + else + { + // convert string to lowercase - each character one by one + int user_query_length = strlen(user_query); + strnlower(user_query, user_query_length); + + struct search_r item = search(user_query, vendors, total_vendors); + if(item.status == 0) + { + char input[10]; + + printf("How many do you want to buy? "); + getstr(input, 10); + + // If a character of a string was sent, the return value would always be 0 + // If a negative number was sent, the return value will always be negative. + + if(atoi(input) > 0) + { + int item_amount = atoi(input); + purchase_r response = purchase(item.item_id, item_amount, vendors); + + if (response.status == 0) + { + printf("You owe %s a total of %d baht.\n", + response.vendor_name, + response.price_owe_baht + ); + } + else + { + printf("\e[31m%s -- %s %s\e[m\n", + "Sorry", + response.vendor_name, + "does not have enough items available" + ); + } + } + else + { + printf("\e[31m%s\e[m\n", + "You must enter a positive whole number for the number of items" + ); + } + + } + else if (item.status == 2) + { + printf("\e[31m%s\e[m\n", + "This item has duplicate records, please choose another item" + ); + } + else + { + printf("\e[31m%s %s\e[m\n", + "No vendor in this market sells", + user_query + ); + } + } + } + + printf("\n>>> End of day details\n"); + + // Print out remaining inventory + for (int i = 0; i <= (total_vendors - 1); i++) + { + if (vendors[i].duplicate == 0) + { + char vendor_info[200]; + sprintf(vendor_info, "%s made %d baht today", + vendors[i].vendor_name, + vendors[i].revenue + ); + + char vendor_stock[50]; + sprintf(vendor_stock, "Remaining inventory %d items", + vendors[i].inventory_count + ); + + printf("%-50s %s\n", vendor_info, vendor_stock); + } + } + + fclose(fp); + free(file_buffer); + return 0; +}; + +/* + getstr: Custom read input function + + Parameters: + - str = string itself + - n = max amount of characters that the function is able to read into buffer + + Reads one character at a time into buffer and adds a null terminator when finish reading +*/ +int getstr(char str[], size_t n) +{ + int ch, i = 0; + + while ((ch = getchar()) != '\n') + { + if (i < (int)n) + { + str[i++] = ch; + } + } + + str[i] = '\0'; + return i; +}; + +/* + strnlower: Convert string to lowercase + + Parameters: + - s: String + - n: Length of string + + Return values: + - (char *): Lowercased version of the string. +*/ +char *strnlower(char *s, size_t n) +{ + for (int i = 0; i < (int) n; i++) + { + s[i] = tolower(s[i]); + }; +} + +/* + Search function + + Parameters: + - (string) query: search query + - (vendor) vendors: the vendor table + - (int) total_vendors: the amount of vendors + + Return values: + (search_r) response: + - status: 0 (Found item) + - status: 1 (No results) + - status: 2 (Found duplicate item) +*/ + +search_r search(char query[], vendor vendors[MAX_VENDORS], int total_vendors) +{ + int i; + for (i = 0; i < total_vendors; i++) + { + // First, check if duplicate + if (strcmp(query, vendors[i].merchandise) == 0) + { + if (vendors[i].duplicate == 0) + { + search_r response; + response.status = 0; + response.item_id = i; + + return (response); + break; + } + else + { + search_r response; + response.status = 2; + return (response); + } + } + }; + + if (i == total_vendors) + { + search_r response; + response.status = 1; + response.item_id = 0; + return (response); + } +}; + +/* + purchase: Purchase function + + Parameters: + - item_id: The item id that the user is purchasing + - amount: How many items that the user is purchasing + - vendors: vendor table + + Return values: + (purchase_r) response: + - status: 0 (Purchase successful) + - status: 1 (Vendor does not have enough items) +*/ + +purchase_r purchase(int item_id, int amount, vendor vendors[MAX_VENDORS]) +{ + if(amount <= vendors[item_id].inventory_count) + { + // Decrease vendor inventory + vendors[item_id].inventory_count = vendors[item_id].inventory_count - amount; + + purchase_r response; + + response.status = 0; + strcpy(response.vendor_name, vendors[item_id].vendor_name); + response.price_owe_baht = vendors[item_id].item_price_baht * amount; + + vendors[item_id].revenue = vendors[item_id].item_price_baht * amount; + + return response; + } + else + { + purchase_r response; + response.status = 1; + strcpy(response.vendor_name, vendors[item_id].vendor_name); + + return response; + } +}; + +/* + check_vendors: Custom function to check if all vendors are empty. + + Parameters: + - vendors[MAX_VENDORS]: (vendor) All of the vendors. + - total_vendors: (integer) Total vendors in market. + + Return values: + - (int) 0: All vendors are empty. + - (int) 1: There are still items left. +*/ + +int check_vendors(vendor vendors[MAX_VENDORS], int total_vendors) +{ + int i; + for (i = 0; i < total_vendors; i++) + { + // Condition: Vendors that are not empty (Check if not marked as duplicates) + if (vendors[i].inventory_count != 0 && vendors[i].duplicate == 0) + { + return 1; + } + } + + if (i == total_vendors) + { + return 0; + } +}; diff --git a/vendor2.data b/vendor2.data index e16e365..01a02f3 100644 --- a/vendor2.data +++ b/vendor2.data @@ -8,6 +8,7 @@ Oat watches 9 120 Lila jackets 7 380 Mary toys 17 39 Kitty dishes 11 67 +Win books 30 165 Pat comics 22 18 Jay shoes 22 300 Mark dvds 10 200 diff --git a/vendorInfo b/vendorInfo index 2131c0ba473fa87fdce22ca9ec86763a3ba4e454..520f6d06d04450732b84ac136d9cc81c5af57523 100755 GIT binary patch delta 2992 zcmaJ@eNa@_6~A{`78WDB3k&_}TXqn&o5O*>sg4YXEKXWEUJ?GqW@4N3sdii88k629+lf4l9A4P5c)+p-m<4NTml z4`>xF0AJxA{t@irvT3wPv5gi2C#OG6H-IIfza44;o z7lBD@;ZF!zC!`&!wHqOlZiSucRvr?zJtSdFYvl)o{;ZJQLMFhQZsB1ut`+iaAvcf& z3FoX8qp|f`=+HjFOJFK}xvsULy?sYJ*maKdMjAr7E((9snY|h%ea4xF9l^0t)lUrk zNXJ+j8&qv!dlME$!%l!JV+A)vpULoXo(y5q)H zzF00^?qO`Z8A;qvIwju0i(o#@cV$sk{CjGSqlBO3}O78CsM-Wq{%lZ%hQf*eO~7(=jd?hB!w zzbAKNCTG*@pem<)uM^V>?e9)}Da$dcNT}yrGLFkj*;Y6)G}?9&uP2xcb-kWsVRO6` z?a6PUG0xF(a**KOVDbYEYB7Aoq;l0t4(|R(IJhcUL=dbE1T9o(S7|(@&@P_~&Jbzb zkM42G<(Q-N(K7hUE zyyBfW78{uS0^xJPX=RNX#(IO(T?yV3yge?%`n&>>>b`vH&6$0|Rd@+h=e1;7=aeN2 zyMniQZ}9fo;0425{|00JPqW{}2v`;+$Zz3ve(BceeA9vZnDPD}zHy7X?gVu`XX9sQ z^E!S{mM6@yF*L*{X03wv?4Es*e2CG=HidCxEVZ;n4MV5w>iS9($5MPdzhO=1^Sq^;0VQyMKk}oHEkhgKt}F_HLhLr<2P)w14}% zBSh*-Xit4ln6kpc;u13u3;Z2sANq!y9? zx5MALLwh-??B%4P-#~T5SC`5nA%^42G`e&4Z~^TTj$ z(LeZmaDMTJ*^Dl$P}hyjP}gYY8NB-X`2lC?#vt9n&K<1{Eln-2Ivbms8<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F=$uDD2@b9 h>> Read %d vendors from file %s\n", total_vendors, file_name); @@ -122,13 +128,11 @@ int main() { if ((strcmp(vendors[i].merchandise, vendors[j].merchandise)) == 0) { - vendors[i].duplicate = 1; vendors[j].duplicate = 1; } if ((strcmp(vendors[i].vendor_name, vendors[j].vendor_name)) == 0) { - vendors[i].duplicate = 1; vendors[j].duplicate = 1; } } diff --git a/vendorsmall.data b/vendorsmall.data index 710411e..199d1cc 100644 --- a/vendorsmall.data +++ b/vendorsmall.data @@ -2,3 +2,4 @@ Win phone 1 50 Peter books 1 70 Amy teeshirts 5 100 Deez computers 5 80 +kjflkfdl lkdfjlkslkfslklk sdfdsjf dslkfjdslfkjs