added search function, still incomplete

This commit is contained in:
Win 2024-08-31 11:16:43 +07:00
parent e0ca79c4d0
commit d8fc155229
4 changed files with 29 additions and 2 deletions

Binary file not shown.

View File

@ -7,12 +7,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MAX_VENDORS 20
#define MAX_FILENAME_LENGTH 4096
int read_input(char str[], int n);
struct vendor_item
{
char vendor_name[20];
@ -21,6 +20,9 @@ struct vendor_item
int item_price_baht;
} vendors[MAX_VENDORS];
int read_input(char str[], int n);
int search(struct vendor_item vendors[MAX_VENDORS], char query[]);
int main()
{
char file_name[MAX_FILENAME_LENGTH];
@ -81,8 +83,14 @@ int main()
printf("%-50s %s\n", vendor_info, vendor_stock);
}
<<<<<<< HEAD
char user_purchase[50];
=======
char query[100];
read_input(query, 100);
search(vendors, query);
>>>>>>> ff1cef9 (added search function, still incomplete)
fclose(fp);
free(file_buffer);
@ -105,9 +113,27 @@ int read_input(char str[], int n)
return i;
};
<<<<<<< HEAD
int purchase(struct vendor_item vendors, int index, char str[], int amount)
{
}
=======
int search(struct vendor_item vendors[MAX_VENDORS], char query[])
{
int query_length = strlen(query);
for (int i = 0; i < query_length; i++)
{
query[i] = tolower(query[i]);
};
printf("Query: %s\n", query);
return 0;
};
int purchase(struct vendor_item vendors[MAX_VENDORS], char str[], int amount)
{
};
>>>>>>> ff1cef9 (added search function, still incomplete)

1
vendorbad.data Normal file
View File

@ -0,0 +1 @@
deez lmao deez deez

0
vendorblank.data Normal file
View File