Ha************* ***@web.de wrote:
Is there a special function to insert a string into another string ?
For example I want to exchange the german "Umlauts" ä,ö,ü with ae,oe
and ue in a string.
No, but there are [1] functions like strchr() and strcspn()
that can help you find the ä,ö,ü,... in the original string,
[2] functions like malloc() and realloc() to allocate memory
for the longer result string, and [3] functions like strcpy(),
strcat(), memcpy(), and memmove() to copy strings or string
segments from one place to another.
I also wonder if there is a function to get the alphabet of a string ?
Do two strings share the same alphabet ?
No, but you can do this for yourself easily enough. If
all you care about is the set of characters from which the
string is formed (rather than, say, the count of how many
times each character appears), you could do something like
unsigned char alphabet[1+UCHAR_MAX];
memset (alphabet, 0, sizeof alphabet);
for (ptr = theString; *ptr != '\0'; ++ptr)
alphabet[ (unsigned char)*ptr ] = 1;
.... after which the array alphabet[] will contain a 1 in each
position that corresponds to a character in the string, and a
0 for each character that is not present. To compare the
alphabets of two strings, use memcmp() on their arrays.
Note that this technique assumes one "character" is one
char, one byte. If multi-byte encodings are a concern you
will need to work harder.
P.S.: What book can you recommand your C and/or C++ ?
Kernighan and Ritchie.
Don´t say
Kernighan & Ritchie.
Oops! Sorry; it just slipped out.
Should be useful not only to learn but also to
look up things.
--
Eric Sosman
es*****@ieee-dot-org.invalid