int转char是保留低地址还是高地址
时间: 2023-12-27 11:03:36 浏览: 52
c代码-CCCC int转char
根据引用\[3\]中的解释,当将一个int类型的值赋给char类型的变量时,只会保留低8位的值。这是因为char类型在内存中只占用2个字节,而int类型占用4个字节。因此,高位的值会被丢弃。所以,int转char是保留低地址的值。
#### 引用[.reference_title]
- *1* *2* [为什么int类型可以直接赋值给char类型?](https://blog.csdn.net/u011453680/article/details/128460624)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [给char赋超过范围的值会发生什么](https://blog.csdn.net/justhere_/article/details/108113773)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文