永发信息网

嵌入式系统经常具有要求程序员去访问某特定的内存位置的特点. 在某工程中,要求设置一绝对地址为0x67a9的整

答案:1  悬赏:50  手机版
解决时间 2021-04-08 03:04
  • 提问者网友:饥饿走向夜
  • 2021-04-07 04:31
嵌入式系统经常具有要求程序员去访问某特定的内存位置的特点. 在某工程中,要求设置一绝对地址为0x67a9的整
最佳答案
  • 五星知识达人网友:空山清雨
  • 2021-04-07 05:48
楼主自己说得很详细了,"这一问题测试你是否知道为了访问一绝对地址把一个整型数强制转换(typecast)为一指针是合法的.",后面应该是笔误,也不是重点。这样的基础问题,最基本的C资料就有说明,不管是上论坛提问题还是网上搜索,最好还是先自己查阅下书籍资料 .
05/14追加
看来楼主还是不相信我说的,百度知道的专业性还是太差了。我基本不用知道,这个账号只是为看看百度云,从没回答过问题。只是这个问题引起了我的好奇。
附带英文版的问题和答案:
Q:Embedded systems are often characterized by requiring the programmer to access a specific memory location. On a certain project it is required to set an integer variable at the absolute address 0x67a9 to the value 0xaa55. The compiler is a pure ANSI compiler. Write code to accomplish this task.
A:This problem tests whether you know that it is legal to typecast an integer to a pointer in order to access an absolute location. The exact syntax varies depending upon one's style. However, I would typically be looking for something like this: int ptr; ptr = (int )0x67a9; ptr = 0xaa55; A more obscure approach is: (int * const)(0x67a9) = 0xaa55; Even if your taste runs more to the second solution, I suggest the first solution when you are in an interview situation.
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯