Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!mit.eternal-september.org!.POSTED!not-for-mail From: Richard Newsgroups: comp.lang.c Subject: Re: cpy functions Date: Tue, 29 Apr 2014 00:20:30 +0200 Organization: http://www.ieee.org/ Lines: 41 Message-ID: <87bnvl3xld.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mit.eternal-september.org; posting-host="07eb11d006e4bc5020972c87fef4388d"; logging-data="14278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Vpe4+0Fw2VWlJ6DXs0Hw9Y7qf98+RflY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:yQ9nyoJ6gzaQmg0HevQ+eBNmL/4= sha1:dCoAhy+gdDdRtjuKvKKWno5S5Mg= Xref: csiph.com comp.lang.c:43759 Geoff writes: > On Mon, 28 Apr 2014 17:07:31 -0400, "Bill Cunningham" > wrote: > >> >>"Geoff" wrote in message >>news:p4ftl9p41bj9nktk2b71lqfgbeuq2jseg0@4ax.com... >> >>[...] >> >>> memcpy is somewhat more safe. Memcpy doesn't manipulate C strings, >>> only bytes, it knows nothing of zero termination it copies without >>> judgement of the content it's copying. It takes three arguments, a >>> destination, a source and a length. As long as length is <= the size >>> of destination the copy will only copy the number of bytes that >>> destination is expected to hold. Of course, you can still create >>> problems for yourself if the source and destinations overlap or if you >>> use a length greater than the destination. >> >>char *a="String one"; >>char *b="String two"; >> >>memcpy(a,b,sizeof(a+b)); > WTF!---------------^^^ > > That is wrong on two levels: > 1. You don't SUM two lengths to get the destination length. > 2. You don't SUM two pointers to get the length of anything. > >> >>Is that a "strcpy" like representation? Atleast to an extent. >> > No, it's not even close. > If you are going to use strings explicitly then use strcpy. LOL! You're not serious are you? -- "Avoid hyperbole at all costs, its the most destructive argument on the planet" - Mark McIntyre in comp.lang.c