|
1
2 3 4 5 6 |
void foo(
void)
{ unsigned int a = 6; int b = - 20; (a + b > 6) ? puts( ">6") : puts( "<=6"); } |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 |
void foo(
void)
{ char string[ 10], str1[ 10]; int i; for(i = 0; i < 10; ++i) { str1[i] = 'a'; } strcpy(string, str1); printf( "%s\n", string); } |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
static
int j;
int k = 0; void fun1( void) { static int i = 0; i++; } void fun2( void) { j = 0; j++; } int main( void) { for( int k = 0; k < 10; ++k) { fun1(); fun2(); } return 0; } |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include
"stdio.h"
#include "string.h" int main( void) { signed char a[ 1000]; int i; for(i = 0; i < 1000; ++i) { a[i] = -i - 1; } printf( "%d\n", strlen(a)); return 0; } |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 |
#include
"stdio.h"
int main( void) { int a[ 5] = { 1, 2, 3, 4, 5}; int *ptr1 = ( int*)(&a + 1); int *ptr2 = ( int*)(( int)a + 1); printf( "%x, %x\n", ptr1[- 1],*ptr2); return 0; } |
|
1
2 3 4 5 6 7 8 9 10 11 12 |
#include
"stdio.h"
int main( void) { int a[ 5] = { 1, 2, 3, 4, 5}; int *ptr = ( int*)(&a + 1); printf( "%d, %d\n", *(a + 1),*(ptr - 1)); return 0; } |
|
1
2 3 4 5 6 7 8 9 10 11 12 |
#include
"stdio.h"
int main( void) { int a[ 3][ 2] = {( 0, 1),( 2, 3),( 4, 5)}; int *p; p = a[ 0]; printf( "%d\n", p[ 0]); return 0; } |
|
1
2 3 4 5 6 7 8 9 10 11 12 |
void fun(
char a[
10])
{ char c = a[ 3]; } int main( void) { char b[ 10] = "abcdefg"; fun(b[ 10]); return 0; } |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include
"stdlib.h"
#include "string.h" struct student { char *name; int score; } stu, *pstu; int main( void) { pstu = ( struct student *)malloc( sizeof( struct student)); strcpy(pstu->name, "Jimy"); pstu->score = 99; free(pstu); return 0; } |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 |
#include
"stdio.h"
void fun( int i) { if(i > 0) fun(i/ 2); printf( "%d\n", i); } int main( void) { fun( 10); return 0; } |
716




被折叠的 条评论
为什么被折叠?



