typedef struct treeNode
{
int data,pos;
char name[16];
struct treeNode *left;
struct treeNode *right;
}treeNode;
我已經創建了一個動態對象
treeNode *temp;
temp = (treeNode *)malloc(sizeof(treeNode));
如果非要賦值的數據應該怎麼分配
scanf("%d",temp->data); //or
scanf("%d",&(temp->data)); //why? because all scanf will look for is address to a location which could be done by temp->data;
和我的結構的Def這也適用於訪問數據也即我應該如何訪問整數部分?
temp->data; //or
*(temp->data)
[不要強制'malloc'](http://stackoverflow.com/a/605858/1848654)。 – melpomene