Struct, Dynamic memory - functions ? Define a struct Rect as follows: typedef st
ID: 3530252 • Letter: S
Question
Struct, Dynamic memory - functions ? Define a struct Rect as follows: typedef struct Rect { double x; double y; char color; double w; //width; double h; //height; } RectT; ? Write a program that declares RectT a, b, *recs; and asks user to enter x, y, w, h of both a and b. ? Write a function int chk_overlap(RectT *r1, RectT *r2) which can be called to check if a and b overlap or not. If so return 1, else return 0. ? Dynamically create an array of 50 rectangles and save their address in recs. Then randomly initialize x, y, w, h of each rectangle (e.g., recs[i].x = rand() ;) ? Count/print how many of these rectangles overlap with a or b. After implementing the program ? Run it with valgrind to see memory usage info > valgrind myprog ? Free the allocated memory then run it again with valgrind ? Compile your program withExplanation / Answer
FOLLOW THIS http://cboard.cprogramming.com/c-programming/120348-structs-dynamic-memory-phone-book-entries.html http://www.cs.cf.ac.uk/Dave/C/node11.html