【发布时间】:2015-08-30 23:45:59
【问题描述】:
我刚刚开始使用指针。所以如果这看起来很傻,请多多包涵 但我无法找到原因。 我有一个结构
typedef struct Intermediatenode
{
int key;
char *value;
int height;
struct node *next[SKIPLIST_MAX_HEIGHT];
} node;
我想使用下面的函数创建一个新节点
node *create_node(int key, char * val, int h)
{
node *newnode;
newnode=malloc(sizeof(node));
newnode->height=h;
newnode->key=key;
printf("till here %s \n",val);
printf("till here %d \n",newnode->height);
printf("till here %d \n",newnode->key);
strcpy(newnode->value,val);
printf("till here %s \n",newnode->value);
return newnode;
}
但是我遇到了分段错误 “strcpy(newnode->value,val);” 你能帮我吗。非常感谢
【问题讨论】: