Discussion Locked

Bubble-up sorting program, Part 3 0f 3

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

double get_amount()
{
int counter;
char amount[40];
int flag;
char input;

for (counter=0; counter <=40; counter++) amount[counter] = 0;

counter = 0;
flag = 0;

while (input=getch())
{
if ( (input >= '0' && input <= '9') )
{
amount[counter]=input;
printf("%c",input);
counter++;
}
if ( input == '.' )
if (!flag)
{
amount[counter]=input;
printf("%c",input);
counter++;
flag = 1;
}
if (input == 13) break;
if (input == 8)
{
for (counter=0; counter <=40; counter++) amount[counter] = 0;
counter=0;

printf("\nLost input, please re-enter: ");
}
}
return atof(amount);
}

int get_menu_input(int count)
{
int input;

while (input = getch())
if ( (input >= 65 && input <= 64+count) ||
(input >= 97 && input <= 96+count) )
break;

printf("%c",input);

if (input < 91)
input = input - 65;
else
input = input - 97;

return input;
}
THANK YOU SO MUCH!

5 replies

This discussion is closed to new replies.