Mail Archives: djgpp/1997/09/02/16:32:58
Orlando Andico (orly AT gibson DOT eee DOT upd DOT edu DOT ph) writes:
> The Joy of Pointers (tm) :)
>
> char *mystring="1234567890";
> char *mid3;
>
> to get characters 5..7 (destructively though)
> mystring[7] = '\0'; /* chop off 8th character and rest */
> mid3 = mystring + 5; /* point to fifth character */
>
> and you're there!!
Or, leave mystring[7] alone and use strncpy or strncat with 'n' equal to 3.
(And you meant mystring + 4 right? mystring + 0 is the first char, + 4 is
the fifth.)
--
.*. Where feelings are concerned, answers are rarely simple [GeneDeWeese]
-() < When I go to the theater, I always go straight to the "bag and mix"
`*' bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh
- Raw text -