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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

c语言结构体中整形数组初始化,c – 将{0,0}在结构体中初始化数组?

發布時間:2023/12/20 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言结构体中整形数组初始化,c – 将{0,0}在结构体中初始化数组? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

A C = {0,0};

8.5.1聚合[dcl.init.aggr] / 12

Braces can be elided in an initializer-list as follows. If the

initializer-list begins with a left brace,then the succeeding

comma-separated list of initializer-clauses initializes the members of

a subaggregate; it is erroneous for there to be more

initializer-clauses than members. If,however,the initializer-list

for a sub- aggregate does not begin with a left brace,then only

enough initializer-clauses from the list are taken to initialize the

members of the subaggregate; any remaining initializer-clauses are

left to initialize the next member of the aggregate of which the

current subaggregate is a member.

[Example:

06001

is a completely-braced initialization: 1,3,and 5 initialize the first row of the array y[0],namely y[0][0],

y[0][1],and y[0][2]. Likewise the next two lines initialize y[1] and

y[2]. The initializer ends early and therefore y[3]’s elements are

initialized as if explicitly initialized with an expression of the

form float(),that is,are initialized with 0.0. In the following

example,braces in the initializer-list are elided; however the

initializer-list has the same effect as the completely-braced

initializer-list of the above example,

06002

The initializer for y begins with a left brace,but the one for y[0] does not,therefore three elements

from the list are used. Likewise the next three are taken successively

for y[1] and y[2]. — end example ]

下一個

8.5.1聚合[dcl.init.aggr] / 7

If there are fewer initializer-clauses in the list than there are

members in the aggregate,then each member not explicitly initialized

shall be initialized from its brace-or-equal-initializer or,if there

is no brace-or-equal- initializer,from an empty initializer list.

在你的情況下,這意味著第一個0被分配給B [0],第二個0分配給B [1].然后根據8.5.1 / 7,其余的元素是值初始化的.

但是,為了清楚這種情況,您應該使用A C = {{0},0};或者更好

A C{}; // or A C = {};

唯一讓我擔心的是g警告(-Wextra):

warning: missing initializer for member ‘main()::A::D’

[-Wmissing-field-initializers] A C {0,0};

但是根據我對上述標準的解釋,你應該是OK,D應該被初始化.我甚至測試了一些新的布局,結果是如預期的

#include

int main()

{

struct A { int B[100]; int D;};

A memory{};

memory.D = 42;

std::cout << memory.D << std::endl;

// let's place something an A at the location of memory

A* foo = new (&memory) A{0,0};

// line below outputs 0,so D is erased; not the case if A* foo = new (&memory) A;

std::cout << memory.D << std::endl; // outputs 0

}

總結

以上是生活随笔為你收集整理的c语言结构体中整形数组初始化,c – 将{0,0}在结构体中初始化数组?的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 色婷婷婷 | 欧美亚洲精品天堂 | 黄色免费av | 樱桃视频污污 | 亚洲成人激情视频 | 欧美色图一区二区 | 痴女扩张宫交脱垂重口小说 | 一级绝黄 | 日韩在线一区二区 | 成人av一区 | 在线91av| 日韩特级 | 黄色大片一级片 | 色涩涩 | 日韩啪啪网 | 免费看黄网站在线 | wwwxx欧美| 日韩av一区在线播放 | 欧美丝袜脚交 | 欧美r级在线观看 | 日日夜夜操操操 | 午夜窝窝 | 日本三级aaa| 久久午夜精品 | av成人免费在线观看 | 99久久免费看精品国产一区 | 欧美无遮挡高潮床戏 | 永久免费看黄 | 好吊色视频在线观看 | 欧美午夜精品久久久 | 欧美亚洲另类图片 | 日本一级淫片色费放 | av免费在线网站 | 久久一视频 | 亚洲精品久久久久久国产精华液 | 成人毛片在线免费观看 | 欧美www.| 奇米第四色在线 | 双腿张开被9个男人调教 | 日韩在线视频在线 | 国产成人无码性教育视频 | 老汉色老汉首页av亚洲 | 国产精品99久久久久久人 | 人妻av中文系列 | 蜜桃久久久久久 | 亚洲精品免费在线观看视频 | 狠狠爱av| 国产一区在线视频 | 天天操天天干天天 | 一本大道久久a久久精二百 琪琪色在线视频 | 三级视频国产 | 日韩欧美视频在线 | 亚洲美女激情视频 | 日韩精品电影在线 | 日本久久成人 | 无码国产色欲xxxxx视频 | 爱爱免费视频 | 精品久久免费观看 | 日韩欧美中文字幕在线视频 | 婷婷丁香色 | 国产区一区二 | 欧美中文一区 | 亚洲欧美另类日本 | 亚洲国产成人va在线观看天堂 | 中文字幕一区二区三区人妻在线视频 | 亚洲天堂少妇 | 夜夜爽av福利精品导航 | 亚洲免费大全 | 成人av动漫在线观看 | 亚洲视频免费观看 | 黄色链接视频 | 日韩精品五区 | 国产精品成人一区二区三区 | 99re6在线精品视频免费播放 | 国产精品拍拍 | 天堂av网在线| 久久资源总站 | 蜜臀久久精品久久久久 | 剧情av在线 | 色欧美88888久久久久久影院 | 欧美三级电影在线观看 | 朝桐光一区二区三区 | 欧美精品免费在线 | 国产一区二区综合 | 福利视频免费观看 | 国产精品18 | 91亚洲精华国产精华精华液 | 得得的爱在线视频 | 精品国产伦一区二区三 | 琪琪射| 美女主播福利视频 | 加勒比伊人 | 一区二区成人在线 | 久久免费视频一区二区 | 久久香蕉热| 黄色国产视频网站 | 四虎图库 | 福利视频网站 | 亚洲欧美精品一区二区三区 |