Home > Back-end >  C language structure deposit distribution in the body appear a mistake
C language structure deposit distribution in the body appear a mistake

Time:09-20

# include & lt; Stdio. H>
# include & lt; The malloc. H>
Struct staticlink {
The int data;
Int cur;

};

Typedef struct staticlink * link;
Typedef struct staticlink component;

Void Initlink (link link2) {
int i=0;
for(i=0; i<9. I++) {
If (I==0) {
Link2 [I]. Cur=I + 1;
} else {
The scanf (" % d ", & amp; Link2 [I]. Data);

Link2 [I]. Cur=I + 1;
Printf (" % d \ n ", I);
}
}
Link2 [9]. data=https://bbs.csdn.net/topics/10;
Link2 [9]. Cur=0;
return;

}

Int main () {
The link link2=(link) malloc (10 * sizeof (link));

Initlink (link2);
return 0;
}

Enter the eighth value error don't know why the address didn't cross!! Direct error why the great god

CodePudding user response:

Whether the cause of the compiler

CodePudding user response:

The inside of the sizeof USES the wrong type

CodePudding user response:

Should be the sizeof (component)

CodePudding user response:

I said that I wrong,,,, no wonder,,, thanks

CodePudding user response:

Pointer to a 32-bit system is 4 bytes,
  • Related