所以我有这个结构:
typedef struct type {
int a;
char* b;
} type;
Run Code Online (Sandbox Code Playgroud)
在main程序中,我制作了这些结构的2个数组,并使用malloc():
type *v;
type *w;
v=malloc(50*sizeof(type));
w=malloc(50*sizeof(type));
Run Code Online (Sandbox Code Playgroud)
现在,如果我想释放这些结构数组是正确的:
free(v);
free(w);
Run Code Online (Sandbox Code Playgroud)
?
#include <stdio.h>
#include <stdlib.h>
int f(int x) {
return x;
}
int main ( int argc,char * argv[]) {
int a=4;
f(a);
printf("PASSED!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当你打电话f(a)而没有把它分配给任何东西时会发生什么?