Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

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)??
0
kulesk
Asked:
kulesk
1 Solution
 
szetoaCommented:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now