Greetings,
Roger Smith wrote:
> What is the best way to cut off the end of a char?
>
> char monkey = "poop";
This is a bad example...you can't assign a string constant to
a single char. Either:
char *monkey = "poop";
(however! This is a constant, it can't be changed...)
or: (and what you want)
char monkey[8192];
strcpy(monkey, "poop");
or:
char *monkey;
monkey = strdup("poop");
and
now you can do a simple:
monkey[strlen(monkey)-1] = '\0';
However, for the sanity of your code, the life of your hamster etc. make
sure that monkey is not of zero-length.
- Chris
--
/----------------------------------------------------------------------------\
| Christian Loth, chris@rom.mud.de | REALM OF MAGIC |
| http://rom.mud.de/~chris | telnet rom.mud.de 4000 |
| | http://rom.mud.de/ |
\----------------------------------------------------------------------------/
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST