gpt4 book ai didi

c - 如何组合两个字符类型变量

转载 作者:行者123 更新时间:2023-11-30 18:30:11 25 4
gpt4 key购买 nike

考虑创建两个变量

              char a1,b1,c1; /*consider that im assigning*/

a1='a',b1='b';

/* now i want to combine a1 and b1 and assign to c1
i.e c1='ab' pls suggest me the code to do that.
Dont suggest any complex code im a begineer.

最佳答案

您无法使用常规的 char 变量。要执行您想要的操作,您应该使用 char 数组:

char a1, b1, c1[2];

a1 = 'a';
b1 = 'b';

c1[0] = a1;
c1[1] = b1;

关于c - 如何组合两个字符类型变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32697734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com