Originally Posted by
kbfirebreather
And instead of waiting for my input, it goes onto display my qtype incorrectly as 5, and then display my amount and qtype.
I think it's better to paste your code here. Anyway, it looks like a buffer overflow problem. The problem is that sizeof works in the way you are using it only in the same scope of the array. You can see this clearly by trying the following:
Code:
void how_big_is_it(char *arr) {
printf("%d\n", sizeof(arr));
}
int main(void) {
char buf[100];
printf("%d\n", sizeof(buf)); // prints 100
how_big_is_it(buf); // prints sizeof(void*)
return 0;
}
EDIT: In other words, the other function doesn't "know" how big the array is. The solution is to modify your function to take in this information as extra parameters. E.g. you should make this call instead:
Code:
askUserForAmount(amount, amount_numeric, sizeof(amount_numeric), qtype, sizeof(qtype));