i want to fill both structures with random numbers, i am trying to use pointers but, hmm problems
Code:#include <iostream> #include<time.h> #include<stdlib.h> struct Field { int x; int y; int z; }; struct House { int x; int y; int z; }; void randgen(Field*); int main() { Field ball, *pBall; pBall = &ball; srand((unsigned)time( NULL )); for(int i = 0; i<3; i++) { *(pBall+i) = randgen(&ball) } } void randgen (Field member) { member->x = rand()/ (RAND_MAX / 10 + 1); }




Reply With Quote