日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数据初始化

發布時間:2025/7/14 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数据初始化 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

靜態存儲類未初始化,則自動初始化為0;

全局變量未初始化,則自動初始化為0;

?

1 #include <stdio.h> 2 3 #define LEN 5 4 5 int arr[LEN]; // 全局變量, 數組元素自動初始化為0 6 static int arr2[LEN]; // 局部變量, 數組元素自動初始化為0 7 8 int main(void) 9 { 10 11 int arr3[LEN]; // 自動存儲類未初始化, 垃圾數據 12 static int arr4[LEN]; // 數組元素自動初始化為0 13 14 int arr5[LEN] = {[2] = 3}; // 只初始化某個元素, 其它元素也會被初始化 15 16 17 int i; 18 19 printf("\n%6s", "arr: "); 20 for(i = 0; i < LEN; i++) 21 { 22 printf(" %10d", arr[i]); 23 } 24 printf("\n%6s", "arr2: "); 25 for(i = 0; i < LEN; i++) 26 { 27 printf(" %10d", arr2[i]); 28 } 29 printf("\n%6s", "arr3: "); 30 for(i = 0; i < LEN; i++) 31 { 32 printf(" %10d", arr3[i]); 33 } 34 printf("\n%6s", "arr4: "); 35 for(i = 0; i < LEN; i++) 36 { 37 printf(" %10d", arr4[i]); 38 } 39 printf("\n%6s", "arr5: "); 40 for(i = 0; i < LEN; i++) 41 { 42 printf(" %10d", arr5[i]); 43 } 44 printf("\n"); 45 } arr: 0 0 0 0 0 arr2: 0 0 0 0 0 arr3: 0 0 4195376 0 -1278561728 arr4: 0 0 0 0 0 arr5: 0 0 3 0 0

?

轉載于:https://www.cnblogs.com/itpoorman/p/3944417.html

總結

以上是生活随笔為你收集整理的数据初始化的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。