Re: 請問字串指標!!
※ 引述《junshung@kkcity.com.tw (... (b) pic)》之銘言:
> 請問字串指標 根依班變數型的有啥不同呢??
> 好不容易看懂了變數型指標 又被字串指標給搞混了
> >"<
> 指標是儲存變數位址 那對字串好像不是這樣
> 那它存的是什麼呢 整各字串ㄇ??
C 語言沒有「字串」型別,
所以並沒有「字串指標」一說。
「字串」在 C 語言中,
是指位於記憶體中一個連續的「字元」序列,
其末端的字元為 NULL 值,
這種特性的字元序列就被稱為「字串」。
如同你能用 (int *) 這種 pointer 存取 int array 一般,
你可以使用 (char *) 這種 pointer 存取 char array,
而就上述所說你應該可以歸納得知:「字串就是字元陣列的一種特例。」
換言之,使用 (char *)這種 pointer 就能存取「字串」。
如果你對如何使用 pointer 存取 array 有所不瞭解,
那建議複習一下 pointer arithmetic 這個部分的內容。
--
Name: Tseng, Ling-hua E-mail Address: uranus@it.muds.net
School: National Tsing Hua University Department: Computer Science
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage: https://it.muds.net/~uranus
--
╔═══╗ ┼────────────────────────╮
║狂狷 ║ │* Origin:[ 狂 狷 年 少 ] whshs.cs.nccu.edu.tw ╰─╮
║ 年少║ ┼╮ < IP:140.119.164.252 > ╰─╮
╚╦═╦╝ ╰ * From:61-230-229-253.dynamic.hinet.net
─╨─╨─ KGBBS ─ ◎ 遨翔"BBS"的狂狷不馴;屬於年少的輕狂色彩 ◎
討論串 (同標題文章)
完整討論串 (本文為第 5 之 5 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章