TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: George White
from: Alan Clifford
date: 1998-10-31 15:17:30
subject: character arrays tha

Hello George

Replying to a message of George White to William Mcbrine:

 DC>>> my book on C only talks about predefined character strings, ie:
 DC>>> static char *books[30] = {"moby dick",
"annie", etc}; But not on how
 DC>>> to read data into one.

 WM>> That's an array of pointers to constant strings. You can't read into
 WM>> it.

 GW> Not so :-(. There is no "const" in there...
 GW> That is an initialised array of strings of varying length that retains
 GW> it's value between calls to the function it's declared in. You _can_
 GW> write to them, but it's a dangerous occupation since they have the
 GW> length of the string they were initialised with and so vary in
 GW> length.


Surely *books[30] is an array of thirty pointers to char.  I know my dos
compilers will allow the strings to be changed but "moby dick" is
a string literal.

Alan

"Computers do bite"

--- FleetStreet 1.14 NR
* Origin: Alan's Point on Donor/2 (2:440/4.6)
SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 639/252
SEEN-BY: 670/218
@PATH: 440/4 255/1 251/25 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.