查看完整版本 : C/C++ pointer的計算可以有幾flexible?

kormer 2023-11-7 17:56

純粹分享,有興趣的話可以估估答案。:D

[attach]14768395[/attach]

Zzlaz 2023-11-7 22:21

[quote]原帖由 [i]kormer[/i] 於 2023-11-7 05:56 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=562583862&ptid=31356736][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

純粹分享,有興趣的話可以估估答案。:D

[img]https://img.discuss.com.hk/d/attachments/day_231107/20231107_8465fbbb7d9f46d3a849Yld7NU8lEZuW.png[/img] [/quote]
A, by test it.:smile_44: 
array in C can also be a pointer pointing to the 0th element.
* is to get the corresponding value of the pointer and +1 will help you + the number of byte of the data type
so *(charArr+1) is B. then (long long) cast it (ASCII code 65 is B) , + 1 and treat it as a pointer to integer (66)
the next line is reversed. minus the pointer address by 2 char datatype and get the value, which is A

kormer 2023-11-7 22:56

[quote]原帖由 [i]Zzlaz[/i] 於 2023-11-7 22:21 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562589193&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

A, by test it.:smile_44: 
array in C can also be a pointer pointing to the 0th element.
* is to get the corresponding value of the pointer and +1 will help you + the number of byte of the data typ ... [/quote]
答案對但你再試試啦..

Zzlaz 2023-11-7 23:15

[quote]原帖由 [i]kormer[/i] 於 2023-11-7 10:56 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=562589848&ptid=31356736][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

答案對但你再試試啦.. [/quote]
試答案? 答左啦:smile_22:

蟹於海 2023-11-7 23:33

答案錯但又唔需要再試. :smile_34: :smile_34:

kormer 2023-11-8 08:17

[quote]原帖由 [i]蟹於海[/i] 於 2023-11-7 23:33 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562590527&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

答案錯但又唔需要再試. :smile_34: :smile_34: [/quote]
好多人研究緊 :lol

蟹於海 2023-11-8 11:59

[quote]原帖由 [i]kormer[/i] 於 2023-11-8 08:17 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=562594637&ptid=31356736][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

好多人研究緊 :lol [/quote]

kormer 2023-11-8 14:52

[quote]原帖由 [i]蟹於海[/i] 於 2023-11-8 11:59 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562599135&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

錯 [/quote]
應該唔係啦

蟹於海 2023-11-8 17:09

[quote]原帖由 [i]kormer[/i] 於 2023-11-8 14:52 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=562602639&ptid=31356736][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

應該唔係啦 [/quote]
唔知自己有問題又係好大問題.

Zzlaz 2023-11-8 20:05

pointer to function
[url]https://www.geeksforgeeks.org/function-pointer-in-c/[/url]

kormer 2023-11-8 23:48

[quote]原帖由 [i]Zzlaz[/i] 於 2023-11-8 20:05 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562609725&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

pointer to function
https://www.geeksforgeeks.org/function-pointer-in-c/ [/quote]
怎樣計算?

kormer 2023-11-8 23:48

[quote]原帖由 [i]蟹於海[/i] 於 2023-11-8 17:09 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562605487&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

唔知自己有問題又係好大問題. [/quote]
唔明你講什麼呀

蟹於海 2023-11-9 00:41

[quote]原帖由 [i]kormer[/i] 於 2023-11-8 23:48 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=562614784&ptid=31356736][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

唔明你講什麼呀 [/quote]
所以你既問題一的都唔細 .....

kormer 2023-11-9 07:47

[quote]原帖由 [i]蟹於海[/i] 於 2023-11-9 00:41 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562615418&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

所以你既問題一的都唔細 ..... [/quote]
真的不明呀,看來你有問題?

Zzlaz 2023-11-9 08:34

[quote]原帖由 [i]kormer[/i] 於 2023-11-8 11:48 PM 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562614777&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

怎樣計算? [/quote]
你應該識

蟹於海 2023-11-9 21:52

[quote]原帖由 [i]kormer[/i] 於 2023-11-9 07:47 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=562618229&ptid=31356736][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

真的不明呀,看來你有問題? [/quote]
什麼都不明,什麼都問一餐,
先番去幼稚園 ..... :smile_34: :smile_34: :smile_30: :smile_30: :smile_30:

kormer 2023-11-10 18:43

[quote]原帖由 [i]蟹於海[/i] 於 2023-11-9 21:52 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562633550&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

什麼都不明,什麼都問一餐,
先番去幼稚園 ..... :smile_34: :smile_34: :smile_30: :smile_30: :smile_30: [/quote]
真係咁?其實係問緊其他人... :lol

[video=https://1253590913.vod2.myqcloud.com/743b5de7vodhk1253590913/4396d1115576678021793914156/5576678021793914137.jpg]https://1253590913.vod2.myqcloud.com/743b5de7vodhk1253590913/4396d1115576678021793914156/V6Te49LHINIA.mp4?videoid=5576678021793914156[/video]

蟹於海 2023-11-11 02:14

[quote]原帖由 [i]kormer[/i] 於 2023-11-10 18:43 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=562651422&ptid=31356736][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

真係咁?其實係問緊其他人... :lol

影片 [/quote]
係有問題.....

Zzlaz 2023-11-11 12:14

C++ 好想睇下 有咩資源

kormer 2023-11-12 16:03

C++計算function pointer的例子如下:

[attach]14782746[/attach]

:loveliness:

有興趣可估估輸出。

kormer 2023-11-12 16:06

[quote]原帖由 [i]Zzlaz[/i] 於 2023-11-11 12:14 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=562663715&ptid=31356736][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]

C++ 好想睇下 有咩資源 [/quote]
可以去借圖書
頁: [1]
查看完整版本: C/C++ pointer的計算可以有幾flexible?