Strings.....
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Fri May 5 14:31:00 GMT 2000
> I need a really fast way to do the following:
Please understand that this is the list for help on the GNU C
compiler, not for help with C in general. You cannot really expect
anybody on this list to implement this function for you. Please use
other fora, such as comp.lang.c, where general questions on C are
on-topic.
> char *string;
>
> string = (char *)malloc(sizeof(char)*10);
> string = "Hello\0";
If you really meant to write this, you need to study C in more detail.
When you assign "Hello\0" to string, than the result of the earlier
allocation is lost and garbage. Also, modifying the string won't work
because it is a constant.
To copy overlapping memory, you can use the memmove(3) function.
Regards,
Martin
More information about the Gcc-help
mailing list