This is the mail archive of the
mailing list for the GCC project.
- To: npaulo at linux dot ime dot usp dot br
- Subject: Re: Strings.....
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 5 May 2000 23:18:15 +0200
- CC: gcc-help at gcc dot gnu dot org
- References: <3912B571.CDDE2962@linux.ime.usp.br>
> 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
> 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.