Hello, I'm trying to make Blackjack game using C.
How should I use pointers like global variables?
For example, if variable named money is on the main function and playing function will increase or decrease money.
Hello, I'm trying to make Blackjack game using C.
How should I use pointers like global variables?
For example, if variable named money is on the main function and playing function will increase or decrease money.
I assume you mean something like:
Although you could also do this:Code:#include <stdio.h> void func(int *money) { *money += 100; } int main() { int money = 50; func(&money); printf("%d\n", money); return 0; }
Code:#include <stdio.h> int func(int money) { money += 100; return money; } int main() { int money = 50; money = func(money); printf("%d\n", money); return 0; }