C语言
-
联合体-C语言实例教程|
联合体 #include stdio.h #include string.h union Data { int i ; float f ; char str [ 20 ]; }; int main ( ) { union Data data ; printf ( Memory size occupied by data : %d , sizeof ...
-
指向结构的指针-C语言实例教程|
指向结构的指针 #include stdio.h #include string.h struct Books { char title [ 50 ]; char author [ 50 ]; char subject [ 100 ]; int book_id ; }; /* function declaration */ void...
-
结构作为函数参数-C语言实例教程|
结构作为函数参数 #include stdio.h #include string.h struct Books { char title [ 50 ]; char author [ 50 ]; char subject [ 100 ]; int book_id ; }; /* function declaration */ v...
-
访问结构成员-C语言实例教程|
访问结构成员 #include stdio.h #include string.h struct Books { char title [ 50 ]; char author [ 50 ]; char subject [ 100 ]; int book_id ; }; int main ( ) { struct Books Book1 ...
-
字符串函数-C语言实例教程|
字符串函数 #include stdio.h #include string.h int main () { char str1 [ 12 ] = Hello ; char str2 [ 12 ] = World ; char str3 [ 12 ]; int len ; /* copy str1 into str3 */ strcpy (...
-
打印字符串-C语言实例教程|
打印字符串 #include stdio.h int main () { char greeting [ 6 ] = { H , e , l , l , o , � }; printf ( Greeting message: %s , greeting ); return 0 ; }...
-
从C中的函数返回指针-C语言实例教程|
从C中的函数返回指针 #include stdio.h #include time.h /* function to generate and return random numbers. */ int * getRandom ( ) { static int r [ 10 ]; int i ; /* set the see...
-
接受一个指针-C语言实例教程|
接受一个指针 #include stdio.h /* function declaration */ double getAverage ( int * arr , int size ); int main () { /* an int array with 5 elements */ int balance [ 5 ] = { 100...
-
传递一个无符号长指针-C语言实例教程|
传递一个无符号长指针 #include stdio.h #include time.h void getSeconds ( unsigned long * par ); int main () { unsigned long sec ; getSeconds ( sec ); /* print the actual va...
-
指针的指针-C语言实例教程|
指针的指针 #include stdio.h int main () { int var ; int * ptr ; int ** pptr ; var = 3000 ; /* take the address of var */ ptr = var ; /* take the address of ptr using address of...
-
字符串列表-C语言实例教程|
字符串列表 #include stdio.h const int MAX = 4 ; int main () { char * names [] = { Zara Ali , Hina Ali , Nuha Ali , Sara Ali }; int i = 0 ; for ( i = 0 ; i MAX ; i ++ ) { printf...
-
指针数组-C语言实例教程|
指针数组 #include stdio.h const int MAX = 3 ; int main () { int var [] = { 10 , 100 , 200 }; int i , * ptr [ MAX ]; for ( i = 0 ; i MAX ; i ++ ) { ptr [ i ] = var [ i ]; /* assi...
-
3个整数的数组-C语言实例教程|
3个整数的数组 #include stdio.h const int MAX = 3 ; int main () { int var [] = { 10 , 100 , 200 }; int i ; for ( i = 0 ; i MAX ; i ++ ) { printf ( Value of var[%d] = %d , i , v...
-
指针比较-C语言实例教程|
指针比较 #include stdio.h const int MAX = 3 ; int main () { int var [] = { 10 , 100 , 200 }; int i , * ptr ; /* let us have address of the first element in pointer */ ptr = var ...
-
减少指针-C语言实例教程|
减少指针 #include stdio.h const int MAX = 3 ; int main () { int var [] = { 10 , 100 , 200 }; int i , * ptr ; /* let us have array address in pointer */ ptr = var [ MAX - 1 ]; fo...
-
增加指针-C语言实例教程|
增加指针 #include stdio.h const int MAX = 3 ; int main () { int var [] = { 10 , 100 , 200 }; int i , * ptr ; /* let us have array address in pointer */ ptr = var ; for ( i = 0 ;...
-
NULL(空)指针-C语言实例教程|
NULL (空)指针 #include stdio.h int main () { int * ptr = NULL ; printf ( The value of ptr is : %x , ptr ); return 0 ; }...
-
如何使用指针-C语言实例教程|
如何使用指针 #include stdio.h int main () { int var = 20 ; /* actual variable declaration */ int * ip ; /* pointer variable declaration */ ip = var ; /* store address of var i...
-
变量地址-C语言实例教程|
变量地址 #include stdio.h int main () { int var1 ; char var2 [ 10 ]; printf ( Address of var1 variable: %x , var1 ); printf ( Address of var2 variable: %x , var2 ); return 0 ; }...
-
在C中返回执行数组的指针-C语言实例教程|
在C中返回执行数组的指针 #include stdio.h int main () { /* an array with 5 elements */ double balance [ 5 ] = { 1000.0 , 2.0 , 3.4 , 17.0 , 50.0 }; double * p ; int i ; p ...