Tuesday 15 February 2011

c - assignment makes pointer from integer without a cast - rand() -



c - assignment makes pointer from integer without a cast - rand() -

this question has reply here:

assignment makes pointer without cast 2 answers

ok here problem. using srand first time , getting "assignment makes pointer integer without cast" warning. have read through many threads on here , still don't see wrong. post relevant parts since problem long.

declaration of fucntion

void getfinalsrandom(int*, int*, int*);

function called in main()

int finalsdayrandom; int finalstimerandom; int finalstimerandomsat; getfinalsrandom(&finalsdayrandom, &finalstimerandom, &finalstimerandomsat);

actual code within function

void getfinalsrandom(int *finalday, int *finaltime, int *finaltimesat) { srand(time(null)); finalday = rand() % 6; finaltime = rand() % 5; finaltimesat = rand() % 4; }

i include time.h, stdio.h, stdlib.h, math.h

don't phone call srand in function, phone call 1 time per run of program.

then alter function this:

void getfinalsrandom(int *finalday, int *finaltime, int *finaltimesat) { *finalday = rand() % 6; *finaltime = rand() % 5; *finaltimesat = rand() % 4; }

c pointers integer

No comments:

Post a Comment