0

Mostly just the title, I want to know how I can put the random value which is a long int into an int variable address.

void SpinReel(int *a, int *b)
{
    long int reela = random() % 40;
    a= (int) reela;
    printf("&d\n", a);
    long int reelb = random() % 40;
    b= (int) reelb;
    printf("&d\n", b);

}

I am fairly new to C so I may just be misunderstanding the problem as well.

Soo lee
  • 21
  • 1
  • 2

1 Answers1

0

The parameter a is not an int but a pointer to an int. To assign a value, you need to dereference the pointer.

*a = (int) reela;

What dereferencing a pointer means

Community
  • 1
  • 1
NineBerry
  • 26,306
  • 3
  • 62
  • 93