读书人

就几行代码为何报错内存不可写入,求修

发布时间: 2012-05-13 16:39:43 作者: rapoo

就几行代码为何报错内存不可写入,求修正

C/C++ code
#include "stdio.h"typedef struct VertNode{    char VertexType;}VertNode;void main(){    VertNode *vertNode;    printf("请输入一个顶点类型字符:\n");    scanf("%s",&vertNode->VertexType);    }

为何报错内存不可写入,求修正

[解决办法]
VertNode *vertNode = (VertNode *)malloc(sizeof(VertNode));

读书人网 >C++

热点推荐