hi,
I need to know how to deference a double pointer to a structure.
i have a structure like this.
insert
Code:
struct string1
{
unsigned char line1[20];
unsigned char line2[30];
}
Now there is a function that returns the pointer to this structure.
insert
Code:
struct string1 *linecount()
{
struct string1 string_var;
//I fill the structure elements and return the pointer
return &string_var
}
now in my main function i pass this structure pointer to another function and try to get the values of the structure members.But it gives junk values.
insert
Code:
int main()
{
struct string1 *string_var2;
char temp;
string_var2 = linecount();
temp=string_var2->line1[0]; //Dereferncing works fine here.
func2(string_var2)
}
void func2(struct string1 *num)
{
//when i defernece the pointer iam getting junk values.
char mychar;
mychar=num->line1[0];
}
Please guide me why it happens and the way to solve it.
Regards,
Rohit