Hi there, Im having a bit of a problem returning values from a function.
Basically I want to return a value from an array but when i return I call the function the second time it overrights the first value even though they are stored in two different variables.
Can anyone please help???
This is the function:
char inputMenuChoice()
{
char returnedName;
int MenuChoice;
scanf("%d", &MenuChoice);
if (MenuChoice == 1)
{
strcpy(returnedName, Name[0]);
}
if (MenuChoice == 2)
{
strcpy(returnedName, Name[1]);
}
if (MenuChoice == 3)
{
strcpy(returnedName, Name[2]);
}
if (MenuChoice == 4)
{
strcpy(returnedName, Name[3]);
}
if (MenuChoice == 5)
{
strcpy(returnedName, Name[4]);
}
return returnedName;
}
and it is called like so:
typeFromConvert = inputMenuChoice();
typeToConvert = inputMenuChoice();



LinkBack URL
About LinkBacks



