Home > Back-end > How to structure allocates memory and assignment?
How to structure allocates memory and assignment?
Time:04-10
#include #include
Struct chenjibiao { Char id [10]; Char name [30]. Int chenji; }; Int main () { Int I, n; The scanf (" % d ", & amp; n); //the number of the students in the given Struct chenjibiao students; Struct * p=& amp; Students; P=(struct) students * malloc (sizeof (struct students) * n); for(i=0; I{ The scanf (" % d % s % s ", & amp; P - & gt; Id, & amp; P - & gt; The name, & amp; P - & gt; Chenji); } } Example 3 1234567890 liming 99 5362152436 wangwu 100 4523658967 zhangsan 67 To achieve this should be how to change? Just started to learn C language, please show just a little big,
The scanf (" % d % s % s ", & amp; P - & gt; Id, & amp; P - & gt; The name, & amp; P - & gt; Chenji); Change The scanf (" % d % s % s ", (p + I) - & gt; Id (p + I) - & gt; The name, (p + I) - & gt; Chenji);