you can remove the buy
variable from the printf call, it's unneeded
printf ("\nWould you like to buy a beer (y/n) ?",buy);
And replace char buy
by char buy[2];
. because a sting is always terminated by /0
.
You can also add a memset (buy, 0, sizeof(buy))
, to be sure that memory is reset before you start to use it.