实际上,用scanf对通过指针引用的结构体变量赋值与常规的scanf用法没有差异。举例如下:include <stdio.h>/* 声明结构体 myStruct */struct myStruct{ int x; char s[100];};void main(){ myStruct ms; /*结构体指针*/ myStruct *p = &ms; /** * scanf参数列表需要...
struct student *p=NULL;//此时指针赋值为空(NULL),此时p为空指针,正确的做法是给p分配个指针:include <stdio.h> main(){ struct student { char name[10];int age;};struct student *p=NULL;p = new student;//分配一个 scanf("%s%d",&p->name,&p->age);printf("%s,%d",p->n...
{ char name[10];int age;};struct stud来自ent *p=NU化空孩放重LL;p = new student;//分配一...