udpate and fixes
This commit is contained in:
parent
d64dbde9d4
commit
baa0ed8af9
2
main.c
2
main.c
@ -7,7 +7,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>Up
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#ifndef CUSTOM_H
|
||||
|
@ -76,7 +76,6 @@ void search_item(void * (*showitem)(void *,int)){
|
||||
break;
|
||||
}
|
||||
char* searchstr = prompt_search();
|
||||
printf("searching...\n");
|
||||
map = searchItems(db,searchstr);
|
||||
if(map[0].value > 0){
|
||||
int temp_row = *((int*)map[0].value);
|
||||
@ -100,10 +99,11 @@ void search_item(void * (*showitem)(void *,int)){
|
||||
|
||||
|
||||
char* prompt_search(){
|
||||
printf("Enter search string:(largest length 100)(case insesitive)\n>");
|
||||
printf("Enter search string(largest length 100)\n(case insensitive)\nmatches multiple columns\n>");
|
||||
char* searchstr = malloc(sizeof(char) * 100);
|
||||
fflush_stdin();
|
||||
scanf("%s", searchstr);
|
||||
printf("searching...\n");
|
||||
return searchstr;
|
||||
}
|
||||
|
||||
@ -114,7 +114,11 @@ struct Map* searchItems(struct inventory db, char* searchstr){
|
||||
int k = 1;
|
||||
for (int i = 0; i < db.db.row_count; i++){
|
||||
map[k].key = i;
|
||||
if(strcasestr(db.row[i].product,searchstr) != NULL){
|
||||
if(strcasestr(db.row[i].product,searchstr) != NULL||
|
||||
strcasestr(db.row[i].brand,searchstr) != NULL||
|
||||
strcasestr(db.row[i].category,searchstr) != NULL||
|
||||
strcasestr(lto_string(db.row[i].barcode),searchstr) != NULL
|
||||
){
|
||||
|
||||
map[k].value = (void*)db.row[i].product;
|
||||
k++;
|
||||
|
Binary file not shown.
Binary file not shown.
7
utils.h
7
utils.h
@ -32,6 +32,11 @@ void fflush_stdin(){
|
||||
__fpurge(stdin);
|
||||
#endif
|
||||
}
|
||||
char * lto_string(long num){
|
||||
char * str = malloc(sizeof(char) * 100);
|
||||
sprintf(str,"%ld",num);
|
||||
return str;
|
||||
}
|
||||
|
||||
char * welcome_message(void * ptr){ //cross compatible
|
||||
|
||||
@ -101,7 +106,7 @@ bool item_inputer(char * varname,INPUT_TYPE type,void * item,bool empty_allowed)
|
||||
if(temp == NULL){
|
||||
return false;
|
||||
}
|
||||
switch(type){
|
||||
switch(type){
|
||||
case INT:
|
||||
*((int*)item) = atoi(temp);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user