내 메뉴에 문제가 있습니다. 나는 사용자로부터 숫자를 얻는다.하지만 내가 숫자를 얻을 때마다 나는 내가하는 일에 상관없이 옵션 1을한다. 내가 도대체 뭘 잘못하고있는 겁니까?if/else if/else menu issue c
int main()
{
int array[SIZE];
int size = readNum();
fillArray(array, size);
char option = 'y';
do
{
int num = menu();
if(num == 1)
fillArray(array, size);
else if(num == 2)
{
int newSize = readNum();
fillArray(array, newSize);
}
else
{
sortArray(array);
}
}while(option == 'y');
return 0;
}//end main
int menu()
{
printf("1)Change the values of the array\n2)Change the size of the array and the values in the array\n3)Find and display the mean and median\nChoice: ");
int menuChoice = scanf("%i", &menuChoice);
return menuChoice;
}
'menu()'를 보지 않고 어떻게 잘못했는지 알 수 있습니까? – StoryTeller
'menu()'의 코드는 무엇입니까? 아마 문제가있는 곳일 겁니다. –
'menu'는'1' 만 리턴하기 때문에? 우리에게'menu' 함수도 보여 주시거나, 대답이 불가능합니다. –