By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Can mystr[i]=mystr[ii] be a problem when i==ii

P: n/a
Joe


I have a string parsing function which uses above code. i and ii are same at
first but as my loop goes on ii is incremented more. I could do
if (ii!=i)
mystr[i]=mystr[ii];

but I want to limit unnecessary code.
Jun 12 '07 #1
Share this Question
Share on Google+
27 Replies


P: n/a
Joe said:
>

I have a string parsing function which uses above code. i and ii are
same at first but as my loop goes on ii is incremented more. I could
do if (ii!=i)
mystr[i]=mystr[ii];

but I want to limit unnecessary code.
No, you don't need the test. Well done for asking, though, because it's
not as obvious as it sounds. The relevant rule is:

"Between the previous and next sequence point an object shall have
its stored value modified at most once by the evaluation of an
expression. Furthermore, the prior value shall be accessed only to
determine the value to be stored."

Your code (as written above) obeys this rule, and there is no problem.

It is not difficult to imagine similar code which could fail, however.
For example:

mystr[i] = mystr[i++]; /* BAD! */

would violate the requirement quoted above.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 12 '07 #2

P: n/a
Joe wrote:
>
I have a string parsing function which uses above code. i and ii
are same at first but as my loop goes on ii is incremented more.
I could do
if (ii!=i)
mystr[i]=mystr[ii];

but I want to limit unnecessary code.
I see no 'above code'.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 13 '07 #3

P: n/a
Joe
CBFalconer <cb********@yahoo.comwrote:
With "above code" I mean:
mystr[i]=mystr[ii];
Jun 13 '07 #4

P: n/a
Joe wrote:
>
With "above code" I mean:
mystr[i]=mystr[ii];
You haven't gotten the point. News articles may or may not be
received anywhere. Thus each article should stand entirely by
itself. That means, among other things, proper quoting. The
following sig. may make things clearer.

--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>

--
Posted via a free Usenet account from http://www.teranews.com

Jun 13 '07 #5

P: n/a
["Followup-To:" header set to comp.lang.c.]
On Tue, 12 Jun 2007 18:39:21 -0400 CBFalconer wrote:
Joe wrote:

I have a string parsing function which uses above code. i and ii
are same at first but as my loop goes on ii is incremented more.
I could do
if (ii!=i)
mystr[i]=mystr[ii];

but I want to limit unnecessary code.

I see no 'above code'.
I believe he was referring to the code in the subject line :)

Cheers
/urs

--
"Change is inevitable, except from a vending machine."
-- Urs Beeli, <usenet@CONCAT_MY_FIRST_AND_LAST_NAME.ch>
Jun 13 '07 #6

P: n/a
Urs Beeli said:
["Followup-To:" header set to comp.lang.c.]
On Tue, 12 Jun 2007 18:39:21 -0400 CBFalconer wrote:
> Joe wrote:
>
I have a string parsing function which uses above code. i and ii
are same at first but as my loop goes on ii is incremented more.
I could do
if (ii!=i)
mystr[i]=mystr[ii];

but I want to limit unnecessary code.

I see no 'above code'.

I believe he was referring to the code in the subject line :)
Then he would do well to learn that not everybody uses a newsreader that
displays the subject line conveniently whilst the body of an article is
being displayed.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 13 '07 #7

P: n/a
On Wed, 13 Jun 2007 08:24:20 -0400, CBFalconer <cb********@yahoo.com>
wrote:
>Joe wrote:
>>
With "above code" I mean:
mystr[i]=mystr[ii];

You haven't gotten the point. News articles may or may not be
received anywhere. Thus each article should stand entirely by
itself. That means, among other things, proper quoting. The
following sig. may make things clearer.
<snip>

But will they be received without the Subject line? That it where the
code in question is hiding -- and that makes it a part of every single
post in the thread.

Or does your newsreader display the Subject /below/ the text?
--
"He who should know the history of words
would know all history"
Jun 13 '07 #8

P: n/a
In article <_t******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>I believe he was referring to the code in the subject line :)
>Then he would do well to learn that not everybody uses a newsreader that
displays the subject line conveniently whilst the body of an article is
being displayed.
And those people would do well to complain to their newsreader
suppliers. How can they be so foolish as to not display the subject
readably above the message?

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 13 '07 #9

P: n/a
On Wed, 13 Jun 2007 16:45:05 GMT, in comp.lang.c , Paul S. Person
<ps******@ix.netscom.com.invalidwrote:
>Or does your newsreader display the Subject /below/ the text?
Mine displays it in the titlebar of the window, which is not even
remotely close to the text I'm reading.

But thats hardly the point. Do you write your letter on the outside of
the envelope, and just say "see outside" on the actual paper inside?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 13 '07 #10

P: n/a
On 13 Jun 2007 16:52:46 GMT, in comp.lang.c , ri*****@cogsci.ed.ac.uk
(Richard Tobin) wrote:
>In article <_t******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>>I believe he was referring to the code in the subject line :)
>>Then he would do well to learn that not everybody uses a newsreader that
displays the subject line conveniently whilst the body of an article is
being displayed.

And those people would do well to complain to their newsreader
suppliers.
Why? Its a defect in the poster, not the reader. Do you expect every
page of a book to have the chapter heading readably above the text?
Sure some do, but many don't. Its not regarded as mandatory.
>How can they be so foolish as to not display the subject
readably above the message?
Perhaps because they assumed that the subject would be a brief summary
of the message useful for reading as part of a list of other messages,
and the main text would be in the body, useful for reading as a
message by itself.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 13 '07 #11

P: n/a
In article <b7********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>>>Then he would do well to learn that not everybody uses a newsreader that
displays the subject line conveniently whilst the body of an article is
being displayed.
>>And those people would do well to complain to their newsreader
suppliers.
>Why? Its a defect in the poster, not the reader. Do you expect every
page of a book to have the chapter heading readably above the text?
Your analogy is irrelevant. I wasn't suggesting it should show it
above every page of the message. Obviously it would be absurd to have
a message so long that it went over multiple pages and yet required
you to constantly refer to the title.
>>How can they be so foolish as to not display the subject
readably above the message?
>Perhaps because they assumed that the subject would be a brief summary
of the message useful for reading as part of a list of other messages,
and the main text would be in the body, useful for reading as a
message by itself.
But they were wrong, weren't they.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 13 '07 #12

P: n/a
On 13 Jun 2007 18:06:57 GMT, in comp.lang.c , ri*****@cogsci.ed.ac.uk
(Richard Tobin) wrote:
>In article <b7********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>>Perhaps because they assumed that the subject would be a brief summary
of the message useful for reading as part of a list of other messages,
and the main text would be in the body, useful for reading as a
message by itself.

But they were wrong, weren't they.
Your argument is "idiots might use our software, so lets cater for
them in our interface".

Microsoft Bob anyone?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jun 13 '07 #13

P: n/a
In article <lc********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>Your argument is "idiots might use our software, so lets cater for
them in our interface".
Why is it idiotic to assume that the title will be visible when
reading the start of the article? It's perfectly natural user
interface design. It seems to me that you *want* life to be difficult
for people who happen not to look at things your way.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 13 '07 #14

P: n/a
Richard Tobin said:
In article <lc********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>>Your argument is "idiots might use our software, so lets cater for
them in our interface".

Why is it idiotic to assume that the title will be visible when
reading the start of the article?
FWIW, I don't think it's *idiotic* to assume that. But nevertheless I am
given to understand that it is a false assumption, since (apparently)
there *really are* newsreaders that don't work that way.
It's perfectly natural user
interface design. It seems to me that you *want* life to be difficult
for people who happen not to look at things your way.
For my part, I want life to be *easy* for people who happen not to look
at things my way. My own newsreader does display the subject line in a
convenient way, but I don't insist that everyone uses a newsreader like
mine. Therefore, on the (fairly rare) occasions that I start a new
thread, I don't rely on the subject line being visible to readers of my
article. That is one way in which I try to make life easier for other
people, regardless of their newsreader choice.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 13 '07 #15

P: n/a
Richard Heathfield wrote:
Richard Tobin said:
Why is it idiotic to assume that the title will be visible when
reading the start of the article?

FWIW, I don't think it's idiotic to assume that. But nevertheless I
am given to understand that it is a false assumption, since
(apparently) there *really are* newsreaders that don't work that way.
It's perfectly natural user
interface design. It seems to me that you want life to be difficult
for people who happen not to look at things your way.

For my part, I want life to be easy for people who happen not to look
at things my way. My own newsreader does display the subject line in
a convenient way, but I don't insist that everyone uses a newsreader
like mine.
In mine, it's sort of semi-convenient. It's displayed at the top of the
message, but in a block with other stuff:

From: Richard Heathfield <rj*@see.sig.invalid>
Subject: Re: Can mystr[i]=mystr[ii] be a problem when i==ii
Date: Wed, 13 Jun 2007 23:05:30 +0000
Newsgroups: comp.lang.c
User-Agent: KNode/0.7.1
So, yeah, it's there, but I have to go hunt a bit to find it. It's also
less convenient for replies, as I'd then have to go and make special
arrangements to include that in the reply.

The bottom line is, it's usenet standard practice to fully describe
your question or comment in the body of the message. The subject should
be similar to the headline for a newspaper, a short catchy lead-in to
the main fun.

Brian
Jun 13 '07 #16

P: n/a
ri*****@cogsci.ed.ac.uk (Richard Tobin) writes:
In article <lc********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>>Your argument is "idiots might use our software, so lets cater for
them in our interface".

Why is it idiotic to assume that the title will be visible when
reading the start of the article? It's perfectly natural user
interface design. It seems to me that you *want* life to be difficult
for people who happen not to look at things your way.
Let me summarize.

Usenet client programs *should* conveniently display the subject of a
message when displaying the body of the message, at least when
displaying the first page of the body of the message.

It's not clear that all client programs do this; I don't think I've
ever seen one that doesn't, but there are plenty of client programs
I've never seen.

People posting questions *should* put the question in the body of the
article, and not assume that it's going to be noticed by everyone who
reads the message. This doesn't necessarily mean repeating the
subject verbatim in the body. Most posters here get this right, so
there's no shortage of good examples.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 13 '07 #17

P: n/a
On Jun 14, 9:18 am, Mark McIntyre <markmcint...@spamcop.netwrote:
Your argument is "idiots might use our software, so lets cater for
them in our interface".
That's regarded as a core principle in user
interface design, these days.
Microsoft Bob anyone?
Poor example. Bob was a new user-interaction paradigm
(which turned out to be more difficult to use than
the designers expected), not a catering for idiots.

Jun 14 '07 #18

P: n/a
Richard Tobin wrote:
Richard Heathfield <rj*@see.sig.invalidwrote:
>>I believe he was referring to the code in the subject line :)
>Then he would do well to learn that not everybody uses a
newsreader that displays the subject line conveniently whilst
the body of an article is being displayed.

And those people would do well to complain to their newsreader
suppliers. How can they be so foolish as to not display the
subject readably above the message?
One example is a device with one line text displays. Another may
simply scroll the headers out of the way. Etc.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 14 '07 #19

P: n/a
Richard Tobin wrote:
Why is it idiotic to assume that the title will be visible when
reading the start of the article? It's perfectly natural user
interface design.
Indeed, this 'ere newsreader shows the title above the article
(and the headers). But /that's not where I'm looking/. I'm
looking at the article. It's a flow-killer to go and eyegrope
for the subject (yes, it's highlighted -- the interface is
doing it's best) and it /shouldn't be necessary/.

When the code in the subject line is called "the above code",
that doesn't help.

--
Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Jun 14 '07 #20

P: n/a
Old Wolf <ol*****@inspire.net.nzwrote:
On Jun 14, 9:18 am, Mark McIntyre <markmcint...@spamcop.netwrote:
Your argument is "idiots might use our software, so lets cater for
them in our interface".

That's regarded as a core principle in user interface design, these days.
And it's wrong, because it leads to _everybody_ being treated as idiots.

"My First^w Computer"

Richard
Jun 14 '07 #21

P: n/a
In article <46**************@yahoo.com>,
CBFalconer <cb********@maineline.netwrote:
>And those people would do well to complain to their newsreader
suppliers. How can they be so foolish as to not display the
subject readably above the message?
>One example is a device with one line text displays.
This would equally be a problem for an article that described the
problem on the first line.
>Another may simply scroll the headers out of the way.
It's only relevant for short articles. For longer articles, the start
of the article is going to be just as scrolled-away as the title is.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 14 '07 #22

P: n/a
ri*****@cogsci.ed.ac.uk (Richard Tobin) wrote:
In article <_t******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
I believe he was referring to the code in the subject line :)
Then he would do well to learn that not everybody uses a newsreader that
displays the subject line conveniently whilst the body of an article is
being displayed.

And those people would do well to complain to their newsreader
suppliers. How can they be so foolish as to not display the subject
readably above the message?
They could cleverly display only the message itself in the reader
window, and the thread tree, including the subject, in the thread
browser window.

Richard
Jun 14 '07 #23

P: n/a
On Wed, 13 Jun 2007 18:24:18 +0100, Mark McIntyre
<ma**********@spamcop.netwrote:
>On Wed, 13 Jun 2007 16:45:05 GMT, in comp.lang.c , Paul S. Person
<ps******@ix.netscom.com.invalidwrote:
>>Or does your newsreader display the Subject /below/ the text?

Mine displays it in the titlebar of the window, which is not even
remotely close to the text I'm reading.

But thats hardly the point. Do you write your letter on the outside of
the envelope, and just say "see outside" on the actual paper inside?
The person I am responding to apparently believed that "above" meant
"earlier in the thread". This made his response fall in to the "not
even wrong" category. And that is the point of my post.

And I never said I thought this was a /good/ idea.
--
"He who should know the history of words
would know all history"
Jun 14 '07 #24

P: n/a
On 12 Jun 2007 at 22:39, CBFalconer wrote:
I see no 'above code'.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com
I see a signature in gross violation of Usenet etiquette.

--
CBFalconer: breathtaking hypocrite or insidious troll?
Jun 14 '07 #25

P: n/a
On 13 Jun 2007 at 12:24, CBFalconer wrote:
You haven't gotten the point. News articles may or may not be
received anywhere. Thus each article should stand entirely by
itself. That means, among other things, proper quoting. The
following sig. may make things clearer.

--
If you want to post a followup via groups.google.com, ensure
you quote enough for the article to make sense. Google is only
an interface to Usenet; it's not Usenet itself. Don't assume
your readers can, or ever will, see any previous articles.
More details at: <http://cfaj.freeshell.org/google/>

--
Posted via a free Usenet account from http://www.teranews.com
Like your usual signature, this one breaches basic netiquette: 10 lines,
when a limit of 4 lines is conventional.

And putting part of your message in the sig is just as bad as putting it
in the subject line.

--
CBFalconer: breathtaking hypocrite or insidious troll?
Jun 14 '07 #26

P: n/a
On 14 Jun 2007 at 1:28, CBFalconer wrote:
One example is a device with one line text displays. Another may
simply scroll the headers out of the way. Etc.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com
Pity the person with such a device who has to fight his way through your
sig.

--
CBFalconer: breathtaking hypocrite or insidious troll?
Jun 14 '07 #27

P: n/a
Net Nanny wrote:

Pity the person with such a device who has to fight his way through
your sig.
Ok, that's enough.

*plonk*


Brian
Jun 14 '07 #28

This discussion thread is closed

Replies have been disabled for this discussion.