goto,void,extern,sizeof实例
1.#include <stdio.h>
void func(int n)
{
int* p = NULL;
if( n < 0 )
{
goto STATUS;
}
p = malloc(sizeof(int) * n);
STATUS:
p[0] = n;
}
int main()
{
f(1);
f(-1);
return 0;
}
2.// test.c
#include <stdio.h>
/*
extern "C"
{
int add(int a, int b)
{
return a + b;
}
}
*/
extern int g;
extern int get_min(int a, int b);
int main()
{
return 0;
}
// test2.c
int g = 100;
int get_min(int a, int b)
{
return (a < b) ? a : b;
}
3.#include <stdio.h>
int main()
{
int a;
printf("%d\n", sizeof(a));
printf("%d\n", sizeof a);
printf("%d\n", sizeof(int));
return 0;
}
/******************************** Stay hungry, Stay foolish. @Rocky ********************************/