A89: Re: Strings in C


[Prev][Next][Index][Thread]

A89: Re: Strings in C




> 2 Questions.
> 1. How do you append a string in C
>      TI-BASIC is "string1"&"string2"

Cut from the TI-GCC Library docs:
*****************************
char *strcat (char *dest, const char *src);
Appends src to dest.
strcat appends a copy of src to the end of dest. The length of the resulting
string is strlen(dest) + strlen(src). strcat returns a pointer to the
concatenated strings.
*****************************

You just have to make sure that the dest string has enough space to add the src
string to it, i.e. the sum of both strings' lengths plus one for zero
termination.

> 2. How do you convert a ascii value to a string
> character.

Assuming you have the ascii value in a variable, simply assign a char that value
(for instance, a char inside a string):
 mystring[3] = 65; // equal to mystring[3] = 'A';

--
 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF v5.1 Quote follows:

Johnny had seen films of American shopping malls. They must have different
sorts of people in America, he'd thought. They all looked cool, all the
girls were beautiful, and the place wasn't crowded with little kamikaze
grandmothers.
        -- (Terry Pratchett, Johnny and the Dead)





References: