casting a pointer to structure variable

If:

struct mystruct{
int num1
int num2
char something[10]
}my_s

int *mynum = NULL;

How do you cast "*mynum" to my_s.num1?
*mynum = &my_s.num1 (compile warnings)??
kuleskAsked:
Who is Participating?
 
szetoaConnect With a Mentor Commented:
If I understand your question correctly, you want to assign
mynum to point to num1 inside the structure mynum.  Try this:

mynum = & my_s.num1;

Now you can assign value to mynum:

*mynum = 1; /* for example */

Hope this helps!!!
0
 
kuleskAuthor Commented:
Thanks!
0
All Courses

From novice to tech pro — start learning today.