|
-
June 5th, 2012, 03:51 AM
#1
Accessing inside structure via a struct pointer to a struct pointer
"
#include <stdio.h>
struct datastructure
{
char character;
};
void function(struct datastructure** ptr);
int main()
{
struct datastructure trial;
struct datastructure *structPtr;
structPtr=&trial;
structPtr->character='a';
function(&structPtr);
}
void function(struct datastructure** ptr)
{
*ptr->character='a';
printf("Ptr: %c",*ptr->character);
}
"
These codes give these errors:
error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*'
error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*'
these errors are related to
"
*ptr->character='a';
printf("Ptr: %c",*ptr->character);
"
I want to access "character" data inside the structure "trial" by a pointer to pointer "ptr" inside function "function",but I couldn't find a way to do this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|