-
Structure array problem
I made my own structure called person it consists of
Code:
struct person
{
char personName[30];
int amLevel;
int noonLevel;
int pmLevel;
};
Now I made an array of this structure called
person patient[25]
This I know limits the number of names I can put into the array to 25, but one name has everything that is in the structure. So when I call the program that has this structure and there is enough data to fill out 15 structures how can I only print out certain names with that name's info? or if there are many occurances of one name? Any help is appreciated. Thanks
So what I'm basically doing is this:
Code:
c:\>program //This calls all the info and displays
c:\>programJohn_Doe //This calls all occurances of that name
c:\>programJohn_Doeam //This calls all John Does and the am level
-
Well, you'd want to use spaces between those arguments, but if you know how to do this:
http://www.cprogramming.com/tutorial/lesson14.html
Then it's simple. Fill in your array, then have a loop that checks argv[1] against the values in patient[25].personName[x]. If it finds a match it outputs it. Also if argc > 2, then it can check the next argument against the appropriate variable, etc.
-
Now that helped a lot. Didn't think to use the argc and argv except in my switch statement. Appreciate the help. Thanks a lot.