【发布时间】:2020-11-23 10:29:57
【问题描述】:
我已经将数组的元素转移到 printf 我需要转移到一些 variable 的 string/bits,因为我需要使用这个 text /string (01000001) 并将其转换为 char (bits => char)。
//main
bool bits2[8] = {0,1,0,0,0,0,0,1};
printf("%c\n", decode_byte(bits2));
//function
char decode_byte(const bool bits[8]){
int i;
for (i=0; i<8; i++){
printf("%d", bits[i]);
}
return 0;
}
【问题讨论】:
-
不清楚你在问什么。你想得到什么结果?
-
您的意思是在函数解码 {01000001} 时返回“A”?
-
@Fawad 是的,我的意思是……从控制台中的 printf 或数组 {01000001} 中返回“A”的函数