【发布时间】:2014-05-28 06:08:55
【问题描述】:
我正在用 C 语言在 uVision 4 上进行 ARM 作业编码。 我似乎无法弄清楚,但每次我不断得到字符串“536876144”。
int main(void) {
int binary[8] = {0,0,0,0,0,0,0,0};//I want this array as integers (for binary terms), therefore i can toggle each number as 1 or 0, corresponding to the input.
char stringbinary[9]; //string for recording the value of the converted integer array
sprintf(stringbinary, "%d", binary);//conversion of the array to string
printf("%s\r\n",stringbinary);//printing the value
.............
.............
if(input=1){
binary[0]=1 - binary[0]; // I have the each value of the array to toggle with activation
}
}
这可能只是因为我在编码数小时后感到疲倦。我很确定这是一些简单而基本的东西,但我似乎找不到它。
【问题讨论】:
-
if(input=1)应该是if(input == 1)和int binary[8] = {0};足够了,剩下的部分会被隐式初始化为0 -
结果不是你说的“随机”,是
binary的地址
标签: c arrays int arm stm32f4discovery