2021年1月7日星期四

How to implement a menu in C that works like checkboxes

I'm working on a console program that allows to search in an array of a structure named Person for simplicity I'm now assuming that all of the attributes are integers.

typedef struct Person {  int name;  int city;  int email;  } Person;  

so the comparing function will be like this:

int comparing(int x, int y) {  return x == y;  }  

My problem is the searching function, because the user may want to search based on more than one criteria, for example he may want to show users Persons that are with the name 6 and city 55, I thought about it for a while and still couldn't figure out how to implement my menu, because it has to work a bit just like checkboxes, user needs to specify which type criteria he wanna use and then specify the criteria, and then of course I need to search based on these criteria, I hope my problem is clear and hope you can help. it's possible to just hardcode this with bunch of if statements but it's not clear in my mind and i hope there are even better approaches.

https://stackoverflow.com/questions/65622654/how-to-implement-a-menu-in-c-that-works-like-checkboxes January 08, 2021 at 10:33AM

没有评论:

发表评论