#include <stdio.h>
#include <string.h>
// #include <stdlib.h> //if open ,error occur.
typedef struct stu
{
char *name;
int soc;
int ll;
};int main()
{
struct stu st;
st.name = ( char *)malloc(sizeof( struct stu)); //if struct use '->',error occur!!!!
strcpy(st.name,"asfghjkll ");
st.soc=99;
printf("st.name is %s\n",st.name);
printf("st.soc is %d\n",st.soc);
printf("st.soc is %d\n",sizeof( st)); //size of st.name is 4.in vc++6.0.free(st.name);
return 0;
}
为结构体成员分配内存(vc++6.0调试)
猜你喜欢
转载自blog.csdn.net/iyy123IUU/article/details/88050146
今日推荐
周排行