C中的char []操作(char[] manipulation in C)

编程入门 行业动态 更新时间:2024-10-26 02:29:56
C中的char []操作(char[] manipulation in C)

假设我定义了以下内容:

unsigned char temp[2][13];

什么是默认值将分配给此char[] ? 它就像{'', '', '', ... , ''} ?

在我的程序(计算器)中,我有operand[2][13] (其中第一个操作数是operand[0] ,第二个操作数是operand[1] ),我有操作和Result[15] ,它们都是unsigned char 。 Fisrt,用户将进入Operand1和Operand2(一次一个字符),它将存储在operand[2][13]然后程序将结果存储为Result[15]字符。 现在我想要的是,在下一次迭代中,我想清除operand[2][13] ,操作和Result[15]以便用户可以输入下一个操作数,程序执行下一个操作并将结果保存在Result[15] 。

我该如何清除这些数组?

Suppose I define the following:

unsigned char temp[2][13];

What is the default values will be assign to this char[]? Is it like {'', '', '', ... , ''}?

In my program (The calculator), I have operand[2][13] (where first operand is operand[0] and second operand is operand[1]) and I have Operation and Result[15] and they are all unsigned char. Fisrt, the user will enter Operand1 and Operand2 (A char at a time) and it will be stores in operand[2][13] then the program will store the result as chars in Result[15]. Now what I want is, at next iteration, I want to clear operand[2][13], operation and Result[15] so that the user can enter next operands and the program executes next operation and saves the result in Result[15].

How can I clear these arrays?

最满意答案

memset (operand, 0, 2 * 13); memset (Result, 0, 15); memset (Result, 0, 15);

memset(operand, 0, 2 * 13); memset(Result, 0, 15);

更多推荐

本文发布于:2023-08-04 15:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1418853.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   char   manipulation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!