From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,decb0c44a2cbd5dc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-18 11:46:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: How to delete charcters in a string? Date: 18 Feb 2002 14:44:52 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <4519e058.0201310647.3637d7a9@posting.google.com> <7Q_b8.8417$BR3.454358@bgtnsc04-news.ops.worldnet.att.net> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1014061759 6047 128.183.220.71 (18 Feb 2002 19:49:19 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 18 Feb 2002 19:49:19 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:20112 Date: 2002-02-18T19:49:19+00:00 List-Id: "David Thompson" writes: > Pascal Obry wrote : > > > > Stephen Leake writes: > > > > > tmoran@acm.org writes: > ... > > > > How would you delete a character from a C string? Seems to me that's > > > > probably harder that with an Ada string (lack of slice assignment), > > > > > > char *S1 = "ABCDEF"; > > > > > > strncpy (S1 + 3, S1 + 4, 3); > > > > > > result in *S1 is "ABDEF". > > > > No it's not. All C arrays, including strings, are zero-origin, > so _if_ this worked it would produce ABCEF. But: Ok. Never post code that hasn't been run, even if it is C :). > 1) you can't legally modify (store to) a string literal value. > _Some_ implementations put them in readonly storage and this will > fault. _Some_ implementations share storage for > identical(ly-suffixed) values, Right. I should have added an extra strcpy to a variable. > Note char foo[] = "ABCDEF" is different. That allocates > space and _initializes_ it by copying the literal value -- > at least notionally, for static-duration variables the copy > is often embedded in process creation -- and it can then > be legally modified; but see next. Hmm. I guess this is a case where array is _not_ defined in terms of pointer. I had not noticed that before. Guess I can learn stuff even about C still :). > > > No where near as pretty or readable as Ada, but just as short and > > > easy. And I've probably got the "src" and "dest" parameters swapped. > > > Man, I hate C :). > > > Actually (dest,src,len) is the only part you got right. > I decline to guess what if anything this signifies. Me too :). -- -- Stephe