I have 2 struct
s:
struct A
{
B *b;
}a;
struct B
{
int* Info;
} b;
How do I perform memset
of info in C?
memset((a->b->Info,0,sizeof(int));
Info has to be memset
with 0. This has to be done for 34 values. Can that be done through for loop?
Thanks in advance!
When you define a struct, you're actually creating a user defined data type. In your code above, A is the datatype, a is the variable of that type. Same goes for B and b.
a.b -> Info
is how you should access Info via A, in your case..
operator is used to access members of a stuct using a normal struct variable (non-pointer). If you defined a pointerx
of type A, then you should usex->b->Info
.You can learn about C structures from here:
http://www.tutorialspoint.com/cprogramming/c_structures.htm