At your request, here is some code to get you started. But the missing tidbits are for you to fill in:
Code:
/*ENTER RETURN TYPE HERE*/ return_price(/*ENTER NECESSARY PARAMETERS HERE*/)
{
int x, compare_result;
char SearchForThisName[30];
//ADD SOME CODE WHICH READS IN THE SEARCH NAME FROM THE USER
for(x = 0; x < TotalItem; x++)
{
//This compares whether or not SearchForThisName and Item[x].name are equal.
//If "equal", then it means that every letter in SearchForThisName corresponds
//to every letter in Item[x].name, and vice versa. Any difference in capital
//letters or spacing will not result in an "equal" answer.
compare_result = strcmp(SearchForThisName, Item[x].name);
//These next If Statements decide how your program reacts based on
//the return value of strcmp()
if(compare_result > 0)
{
//YOUR JOB TO FIGURE OUT WHAT GOES HERE (IF ANYTHING)
}
else if (compare_result < 0)
{
//YOUR JOB TO FIGURE OUT WHAT GOES HERE (If ANYTHING)
}
else if (compare_result == 0)
{
//YOUR JOB TO FIGURE OUT WHAT GOES HERE (If ANYTHING)
}
//Just a note for the If Statements. Once you find the proper item,
//calling:
//return Item[x].price;
//Will not only break you out of the For Loop, but exit the function
//properly, assuming your return type matches the type you are attempting
//to return
}
//If we get here, that means our Item was not located. Therefore
//you should return a specific value which you know will never be
//returned (or shouldn't under normal circumstances). For example,
//have you ever paid -1 dollars for an item? The choice is yours
//what to choose though. If you're returning a character, maybe make
//it "$". If you're returning a float or double, again, a negative
//number would be handy. I think you get the idea.
}
For more information on strcmp(), click HERE
Hope this gets you on the right foot.