simple Struct question
here is the code:
In the function call for get_item_name I pass the value of upc which can be a char A through I. I am supposed to retrieve the matching name (each value of upc has a corresponding name) and print it. So, itemList.upc has value 'A' and itemList.name has value "corn", and itemList.upc is 'B' and itemList.name is "candy", and so on. Is this a possible operation with this type of setup? This code is what our professor gave us to start with.
I doubt your professor would give an assignment that wasn't possible. If you look at the data structure you know that when you find one item you also have found the other.
I do not have the index number to the array. I only have the value of the char upc, and with that need to match up the value of "name" and print it. If I knew what index in the array the specific upc was at it would be easy.
Your task is to find the name when given the upc both of which are stored in the same struct you have an array of structures essentailly a list what would you do with a list? If you had a list on paper you would scan each entry looking for the one that matched right? so go through the list compareing each entry to the one you want to find and when you find it output the name.
thank you sir, i think that will help me a great deal!