Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: string swap |
| Date | 2016-07-31 17:16 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87h9b5wzop.fsf@bsb.me.uk> (permalink) |
| References | <6461d9d8-9101-47e4-a0a5-7609a32b8ec1@googlegroups.com> |
sinbad <sinbad.sinbad@gmail.com> writes:
Just an extra note...
> int
> swap(char *s, int src, int dst)
> {
> int tmp;
>
> tmp = *(s + src);
> *(s + src) = *(s + dst);
> *(s + dst) = tmp;
*(s + src) is the same as s[src] and I don't see any advantage in
avoiding the more obvious subscript notation here.
Also, it's probably more idiomatic to pass two pointers rather than one
pointer and two indexes, but that raises the whole question of what this
function is really for.
> return(0);
> }
<snip>
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
string swap sinbad <sinbad.sinbad@gmail.com> - 2016-07-31 07:45 -0700
Re: string swap Melzzzzz <mel@zzzzz.com> - 2016-07-31 16:51 +0200
Re: string swap Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-07-31 12:48 -0400
Re: string swap James Kuyper <jameskuyper@verizon.net> - 2016-07-31 11:14 -0400
Re: string swap Real Troll <real.troll@trolls.com> - 2016-07-31 15:43 -0400
Re: string swap "James R. Kuyper" <jameskuyper@verizon.net> - 2016-08-01 12:55 -0400
Re: string swap "James R. Kuyper" <jameskuyper@verizon.net> - 2016-08-01 15:35 -0400
Re: string swap supercat@casperkitty.com - 2016-08-01 13:09 -0700
Re: string swap Keith Thompson <kst-u@mib.org> - 2016-08-01 14:36 -0700
Re: string swap jameskuyper@verizon.net - 2016-08-01 15:58 -0700
Re: string swap raltbos@xs4all.nl (Richard Bos) - 2016-07-31 15:38 +0000
Re: string swap Tim Rentsch <txr@alumni.caltech.edu> - 2016-07-31 12:42 -0700
Re: string swap Randy Howard <rhoward.mx@EverybodyUsesIt.com> - 2016-07-31 18:16 -0500
Re: string swap Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-01 07:33 -0700
Re: string swap raltbos@xs4all.nl (Richard Bos) - 2016-08-03 13:21 +0000
Re: string swap Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-05 09:11 -0700
Re: string swap raltbos@xs4all.nl (Richard Bos) - 2016-08-10 12:56 +0000
Re: string swap Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-17 09:45 -0700
Re: string swap raltbos@xs4all.nl (Richard Bos) - 2016-08-21 12:42 +0000
Re: string swap Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-31 17:16 +0100
Re: string swap Les Cargill <lcargill99@comcast.com> - 2016-07-31 14:28 -0500
csiph-web