我想在编译时用最少的手工工作来初始化char数组。
是否有适用于此
的简写格式char arr[5] = {0x4, 'a', 's', 'd' 'c'};
,例如
char arr[5] = {0x4, "asdc"};
答案 0 :(得分:1)
您可以将字符串中的char与转义序列集成:
- for(var i in rows)
-if (rows[i]['senderID'] == "1" && rows[i]['receiverID'] == "2")
div.direct-chat-msg
div.direct-chat-name.pull-left
div.direct-chat-info.clearfix
span.direct-chat-name.pull-left #{rows[i]['senderID']}
span.direct-chat-timestamp.pull-right #{rows[i]['sentDate']}
img.direct-chat-img(src="/images/users/avatar04.png", alt="alt")
div.direct-chat-text #{rows[i]['message']}
-else if (rows[i]['senderID'] == "2" && rows[i]['receiverID'] == "1")
div.direct-chat-msg.right
div.direct-chat-name.pull-right
div.direct-chat-info.clearfix
span.direct-chat-name.pull-left #{rows[i]['senderID']}
span.direct-chat-timestamp.pull-right #{rows[i]['sentDate']}
img.direct-chat-img(src="/images/users/avatar.png", alt="alt")
div.direct-chat-text #{rows[i]['message']}
-else
div.direct-chat-msg.right
p No message!
div.box-footer
div.input-group
input.form-control(type="text" id="message" placeholder="Write a message...")
span.input-group-btn
button.btn.btn-danger.btn-flat(type="submit" onclick="sendMessageJS()") Send
编辑:更正了数组的wrog长度。
答案 1 :(得分:1)
不,那是不可能的。但你可以做
char arr[] = "\04asdc";
问题在于它不会像你显示的原始数组那样完全,因为它包含字符串终止符,因此有六个元素。