函数指针传递问题
typedef struct{
int last;
}sqlist;
void changesqlist(sqlist *L)
{
L->last=10;
}
如上所示代码,我在主程序调用changesqlist函数,请问通过传递L这个指针,能不能将last改为10???
#include<stdio.h> #include<stdlib.h> typedef struct { int last; }sqlist; void changenum(sqlist *L) { L->last=10; printf("%d",L->last); } main() { sqlist * p; p = (sqlist *)malloc(sizeof(sqlist)); changenum(p); p->last=11; printf("%d",p->last); free(p); }