Searching \ for '[OT]: quick question on C' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/language/index.htm?key=c
Search entire site for: 'quick question on C'.

Exact match. Not showing close matches.
PICList Thread
'[OT]: quick question on C'
2001\01\26@060322 by Oluseyi Odeinde

flavicon
picon face
hello everyone

i came across the following 'for' statement in a code:

for (pass=rx_str[ptr1+1]; ptr1<size && pass; ptr1++) {

i'm curious about about the 'ptr1<size && pass' of the statement as i
have never come across a for loop layed out in this way.
1. is this valid?
2. if so, is it the same as saying 'ptr1<size && ptr1<pass' ?

Thanx in advance
Seyi

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\01\26@061139 by Andy David

flavicon
face
> for (pass=rx_str[ptr1+1]; ptr1<size && pass; ptr1++) {
>
> i'm curious about about the 'ptr1<size && pass' of the statement as i
> have never come across a for loop layed out in this way.
> 1. is this valid?
> 2. if so, is it the same as saying 'ptr1<size && ptr1<pass' ?

       Seyi,

       it means ptr1<size && pass != 0

       There's a very good c-FAQ at: http://www.eskimo.com/~scs/C-faq/top.html


- Andy.
----------------------------------------------
Andrew David, Software Manager, Ultronics Ltd
http://www.Ultronics.com






________________________________________________________________________
This message has been checked for all known viruses, by Star Internet,
delivered through the MessageLabs Virus Control Centre.
For further information visit:
http://www.star.net.uk/stats.asp

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\01\26@064103 by Oluseyi Odeinde

flavicon
picon face
i apologise if this post appears more than once - just realised that the
1st time i sent it, my [OT] channel was turned off!

hello everyone,

i came across the following 'for' statement in a code:

for (pass=rx_str[ptr1+1]; ptr1<size && pass; ptr1++) {

i'm curious about about the 'ptr1<size && pass' of the statement as i
have never come across a for loop layed out in this way.
1. is this valid?
2. if so, is it the same as saying 'ptr1<size && ptr1<pass' ?

TIA
Seyi

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\01\26@064506 by Alok Dubey

flavicon
face
i hnk it is a boolean of  size and pass which is then compared to ptr1
alok


{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2001\01\26@064735 by Alok Dubey

flavicon
face
whoops
make that a boolean AND of size and pass
sorry
alok


{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


2001\01\26@065749 by Oluseyi Odeinde

flavicon
picon face
u lost me there!

Alok Dubey wrote:

> whoops
>  make that a boolean AND of size and pass
> sorry
> alok
>
> > {Original Message removed}

2001\01\26@071244 by D Lloyd

flavicon
face
part 1 3000 bytes content-type:text/plain; charset=us-ascii
Hi,

Its the same as

"for( set initial condition ; termination condition ; iteration condition
)", if you like....where the termination condition is met if 'ptr1' is less
than 'size' AND pass is a non zero value.

Dan




(Embedded     Oluseyi Odeinde <RemoveMEseyispamTakeThisOuTOCEAN.CF.AC.UK>spamTakeThisOuTMITVMA.MIT.EDU>> image moved   26/01/2001 12:00
to file:
pic13186.pcx)





Please respond to pic microcontroller discussion list
     <
PICLISTEraseMEspam.....MITVMA.MIT.EDU>
Sent by:  pic microcontroller discussion list <EraseMEPICLISTspamMITVMA.MIT.EDU>


To:   RemoveMEPICLISTEraseMEspamEraseMEMITVMA.MIT.EDU
cc:
Subject:  Re: [OT]: quick question on C

Security Level:?         Internal


u lost me there!

Alok Dubey wrote:

> whoops
>  make that a boolean AND of size and pass
> sorry
> alok
>
> > {Original Message removed}
part 2 165 bytes content-type:application/octet-stream; (decode)

part 3 105 bytes
--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu


2001\01\26@071624 by Alok Dubey

flavicon
face
pls check he must be using size and pass as hex values..
now he is doing an AND on them i guess.. and that result is being compared
with ptr1
if he used  && he is doing a logical/booloean and.. and watching the result
which can be 0 or 1 and comparing that with ptr1 (the result would be zero
if either size or pass was zero else always 1 even if  either is negative)
if he had used & he was "and"ing the binary numbers  / hex numbers and
taking the result ..so each bit in the binary representation of size and
pass would be ANDed.

Hope this helps ..
use this code.. try changing a and b and see the results

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
main ()
{ int a=254 , b= -1 , c d;
c=(a&&b); d=(a&b)
printf (" %d : %d" , c , d);
}

alok

> {Original Message removed}

2001\01\26@071634 by Alok Dubey

flavicon
face
now .. it is not size "and "pass that would be size&pass
this is size&&pass

Alok

> {Original Message removed}

2001\01\26@073327 by D Lloyd

flavicon
face
part 1 4959 bytes content-type:text/plain; charset=us-ascii
Hi,

Have I got the wrong end of the stick, here, or am I correct in saying
that.........

No: '&' is a bitwise AND, whereas '&&' is boolean AND.

As in, if a port was read to see if one of 8 lights had been turned on

InputPort = 0x8E;
if (InputPort & 0x80)       (bitwise)
{
    // we would get here
    printf("MSB set....Someone turned a light on.");
}

whereas

InputPort = 0x8E;
if(InputPort && 0x80)
{
    // We would not get here!
    printf("InputPort is now equal to 128");
}



Dan





(Embedded     Alok Dubey <RemoveMEadubeyTakeThisOuTspamspamWIPRO.CO.IN>TakeThisOuTspamspamMITVMA.MIT.EDU>> image moved   26/01/2001 12:27
to file:
pic04797.pcx)





Please respond to pic microcontroller discussion list
     <
EraseMEPICLISTspamspamspamBeGoneMITVMA.MIT.EDU>
Sent by:  pic microcontroller discussion list <RemoveMEPICLISTKILLspamspamMITVMA.MIT.EDU>


To:   PICLISTSTOPspamspamspam_OUTMITVMA.MIT.EDU
cc:
Subject:  Re: [OT]: quick question on C

Security Level:?         Internal


now .. it is not size "and "pass that would be size&pass
this is size&&pass

Alok

> {Original Message removed}
part 2 165 bytes content-type:application/octet-stream; (decode)

part 3 105 bytes
--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestSTOPspamspamEraseMEmitvma.mit.edu


2001\01\26@073737 by Oluseyi Odeinde

flavicon
picon face
cheers. makes sense!

for (pass=rx_str[ptr1+1]; ptr1<size && pass>0; ptr1++) {


D Lloyd wrote:

{Quote hidden}

> > > {Original Message removed}

2001\01\26@074122 by D Lloyd

flavicon
face
part 1 4468 bytes content-type:text/plain; charset=us-ascii
Hi,

My mistake......Ignore what I just said.

Dan




(Embedded     Alok Dubey <.....adubeyspam_OUTspamWIPRO.CO.IN>spam_OUTspamMITVMA.MIT.EDU>> image moved   26/01/2001 12:27
to file:
pic17192.pcx)





Please respond to pic microcontroller discussion list
     <
TakeThisOuTPICLIST.....spamTakeThisOuTMITVMA.MIT.EDU>
Sent by:  pic microcontroller discussion list <TakeThisOuTPICLISTKILLspamspamspamMITVMA.MIT.EDU>


To:   .....PICLISTspamRemoveMEMITVMA.MIT.EDU
cc:
Subject:  Re: [OT]: quick question on C

Security Level:?         Internal


now .. it is not size "and "pass that would be size&pass
this is size&&pass

Alok

> {Original Message removed}
part 2 165 bytes content-type:application/octet-stream; (decode)

part 3 105 bytes
--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamspamBeGonemitvma.mit.edu


2001\01\26@074356 by Alok Dubey

flavicon
face
u are right..
& is bit wise and.. thats wht i said..
&& is boolean.. eg a&&b will be zero if either a or b is zero.

but go back to ur code..
the line
inputport&&0x80
would return 1 too! coz the neither inputport nor 0x80 is 0
so u get the
printf ("MSB is 128")
running in that too..


try it .. i did :-)
u either check a&b for 128 that is the safest way to check


what amazes me is why someone is using && .. that to in the code mentioned
by Olyeusi.

well.. thanks for the same.. a good break from some boring socket code here

Alok

> {Original Message removed}

2001\01\26@074948 by Alok Dubey

flavicon
face
whoops.. i already replied :-p
alok


{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspam_OUTspamRemoveMEmitvma.mit.edu


2001\01\26@075425 by Alok Dubey

flavicon
face
i dont know how it makes sense to u ,.. but from wht i see ur ptr1 is never
gona be more than 1
alok


> {Original Message removed}

2001\01\26@084505 by Douglas Wood

picon face
You cannot tell from your "for" code snippet if or how the variables are
being manipulated. From this "for" statement only, your comment would be
true; you'll have to look at the entire program (or at least that section of
code where this statement appears) to determine that.

Douglas Wood
Software Engineer
.....dbwoodspamRemoveMEkc.rr.com

Home of the EPICIS Development Tools for the PIC and SX

----- Original Message -----
From: "Alok Dubey" <adubeyspam@spam@WIPRO.CO.IN>
To: <EraseMEPICLISTRemoveMEspamSTOPspamMITVMA.MIT.EDU>
Sent: Friday, January 26, 2001 7:05 AM
Subject: Re: [OT]: quick question on C


> i dont know how it makes sense to u ,.. but from wht i see ur ptr1 is
never
> gona be more than 1
> alok
>
>
> > {Original Message removed}

2001\01\26@090034 by Oluseyi Odeinde

flavicon
picon face
by the way, b4 going into the for loop 'size' is 28, and and 'ptr1' is 18. so y
do u say ptr1 will never be > 1?. this is what the for loop looks like and as u
can see 'pass' is being decremented

for (pass=rx_str[ptr1+1]; ptr1<size && pass; ptr1++) {
    rx_str[ptr2]=rx_str[ptr1];
    ptr2++;
    pass--;
}

so it would make sense to check that pass stays above 0 rather than ANDing the
values of size and pass together like u suggested.

seyi

Alok Dubey wrote:

> i dont know how it makes sense to u ,.. but from wht i see ur ptr1 is never
> gona be more than 1
> alok
>
> > {Original Message removed}

2001\01\26@090042 by Oluseyi Odeinde

flavicon
picon face
come to think of it, after taking a 2nd look at that statement - i think it
really means:

for (pass=rx_str[ptr1+1]; ptr1<size && pass=1; ptr1++) {

beacuse we are dealing with a boolean AND, therefore for pass to be 'true' it
must equals 1. makes sense?

seyi

Alok Dubey wrote:

> i dont know how it makes sense to u ,.. but from wht i see ur ptr1 is never
> gona be more than 1
> alok
>
> > {Original Message removed}

2001\01\26@090155 by James Paul

flavicon
face
Oluseyi,

What they're saying is that ptr1<size has to be true (a '1'), AND
pass also has to be true (a '1') before the statement is true
(a '1').   So, ptr1, size .. and .. pass are variables (or
constants) that are being tested for tru to make the rest of the
statement happen.

                                          Regards,

                                            Jim





On Fri, 26 January 2001, Oluseyi Odeinde wrote:

{Quote hidden}

spamBeGonejimspam@spam@jpes.com

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspammitvma.mit.edu


2001\01\26@092048 by Bob Ammerman

picon face
----- Original Message -----
From: Alok Dubey <adubeyspamspamWIPRO.CO.IN>
To: <spam_OUTPICLISTspam_OUTspamspam_OUTMITVMA.MIT.EDU>
Sent: Friday, January 26, 2001 6:54 AM
Subject: Re: [OT]: quick question on C

> > for (pass=rx_str[ptr1+1]; ptr1<size && pass; ptr1++) {


> i hnk it is a boolean of  size and pass which is then compared to ptr1
alok

No, '&&' is lower in precedence than '<' so this is treated as:

(ptr1 < size) && pass

which in turn is treated as

(ptr1 < size) && (pass != 0)

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspam_OUTspammitvma.mit.edu


2001\01\26@092251 by James Paul

flavicon
face
All,

It's just a simple comparison.  IF the value of 'ptr1' is less than
the value of 'size' AND if pass is not zero, execute the rest of the
statement.  Otherwise, don't bother.  Just go on with the next
statement.   It doesn't matter if ptr1 ever gets greater than '1'.
As long as it is less than size, then the comparison is true (a '1').
Otherwise, it fails.  Same with 'pass'.  If pass is ever anything
other than '1', it fails, and consequently, so does the whole
statement.  Very simple.  Very easy to understand.

                                          Regards,

                                            Jim





On Fri, 26 January 2001, Alok Dubey wrote:

>
> i dont know how it makes sense to u ,.. but from wht i see ur ptr1 is never
> gona be more than 1
> alok
>
>
> > {Original Message removed}

2001\01\26@092516 by Bob Ammerman

picon face
>
> No: '&' is a bitwise AND, whereas '&&' is boolean AND.

This is correct.

> As in, if a port was read to see if one of 8 lights had been turned on
>
> InputPort = 0x8E;
> if (InputPort & 0x80)       (bitwise)
> {
>      // we would get here
>      printf("MSB set....Someone turned a light on.");
> }

This is correct.

> whereas
>
> InputPort = 0x8E;
> if(InputPort && 0x80)
> {
>      // We would not get here!
>      printf("InputPort is now equal to 128");
> }
>
This is wrong.

InputPort && 0x80 is really shorthand for:

(InputPort != 0) && (0x80 != 0)

So we would get there!

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\01\26@093354 by Alan B. Pearce

face picon face
>ptr1<size && pass

will this not be evaluated as follows ((ptr1<size) && pass) hence the inner
bracket will evaluate as true/false which will then be logically anded with pass
to give a final true/false result.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamBeGonespam.....mitvma.mit.edu


2001\01\26@093834 by Bob Ammerman

picon face
> come to think of it, after taking a 2nd look at that statement - i think
it
> really means:
>
>  for (pass=rx_str[ptr1+1]; ptr1<size && pass=1; ptr1++) {

Well, first, you probably meant to say 'pass==1'.

> beacuse we are dealing with a boolean AND, therefore for pass to be 'true'
it
> must equals 1. makes sense?

But now, a numeric or pointer type is treated as true as long as it is
non-zero (non-null for pointers)

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestspam.....mitvma.mit.edu


2001\01\26@102100 by Stephen B Webb

flavicon
face
>  for (pass=rx_str[ptr1+1]; ptr1<size && pass=1; ptr1++) {
>
> beacuse we are dealing with a boolean AND, therefore for pass to be 'true' it
> must equals 1. makes sense?

No.  When you evaluate a boolean expression with an integer variable,
false is zero, and true is nonzero.

So:

int a=-3;

if(a) {
       cout << "Hello World" << endl;
}



This program would print "Hello World" when run.

-Steve

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\01\26@103228 by Stephen B Webb

flavicon
face
>  Otherwise, it fails.  Same with 'pass'.  If pass is ever anything
>  other than '1', it fails, and consequently, so does the whole
>  statement.  Very simple.  Very easy to understand.
>
>                                            Regards,
>
>                                              Jim

Save your high and mighty bullshit for the times when you are right, Jim.

Your statement:
  "If pass is ever anything other than '1', it fails..."

is incorrect.


For all nonzero values of pass, it is evaluated as TRUE.  It only
evaluates to false when pass==0

-Steve

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestRemoveMEspamEraseMEmitvma.mit.edu


2001\01\26@103703 by Stephen B Webb

flavicon
face
> i came across the following 'for' statement in a code:
>
> for (pass=rx_str[ptr1+1]; ptr1<size && pass; ptr1++) {
>
> i'm curious about about the 'ptr1<size && pass' of the statement as i
> have never come across a for loop layed out in this way.
> 1. is this valid?

Yes, it is valid.  It is unclear code, and I'm not sure that it does what
the author wanted it to do.

> 2. if so, is it the same as saying 'ptr1<size && ptr1<pass' ?

No, it's the same as saying

(ptr1<size) && (pass!=0)


The reason I was suggesting that it may not do what the author intended is
because the first statement:

pass=rx_str[ptr1+1] gets evaluated exactly one time, so pass does not get
updated each loop iteration.  Unless pass is updated in the loop body, or
the programmer intended to only test the 'firsrt' value of pass, then the
code is probably broken.

-Steve

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestspamspamBeGonemitvma.mit.edu


2001\01\26@110623 by James Paul

flavicon
face
Apparently, Mr. Webb didn't read my RESEND of my response where I
caught my 'mistake' and corrected it.   And what is this high and
mighty remark?   I was just answering the question and trying to be
as plain and simple as I could.  I'm sorry you can't understand that.
Seems to me you're the one trying to act high and mighty.  What
language.  What an attitude.

                                       Regards,

                                         Jim





On Fri, 26 January 2001, Stephen B Webb wrote:

{Quote hidden}

RemoveMEjimspamBeGonespamRemoveMEjpes.com

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu


2001\01\26@111308 by rostaman

flavicon
face
Oluseyi:

From the variable name, "rx_str", it appears that
the for loop is traversing an array of characters,
where the "ptr1<size" part is keeping it within the
bounds, and the "pass" part is checking for a NULL
character, or the end of the string.  So, the
"pass" by itself is the same as "if (pass != NULL),
continue", which will break out if a NULL terminator
is seen before the end of the array is reached.

Have fun!
Ross





----         Oluseyi Odeinde <@spam@seyiSTOPspamspam@spam@OCEAN.CF.AC.UK> wrote:
{Quote hidden}

__________________________________________________
FREE voicemail, email, and fax...all in one place.
Sign Up Now! http://www.onebox.com

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspammitvma.mit.edu


2001\01\26@112633 by jamesnewton

face picon face
Calm down guys...

...we don't need flame wars on the PICList.

No further public posts on the issue.

FIRST WARNING.

---
James Newton (PICList Admin #3)
spam_OUTjamesnewtonSTOPspamspampiclist.com 1-619-652-0593
PIC/PICList FAQ: http://www.piclist.com or .org

{Original Message removed}

2001\01\26@113321 by Stephen B Webb

flavicon
face
>  Apparently, Mr. Webb didn't read my RESEND of my response where I

I was responding to your "RESEND", or at lest your second message on the
subject.  Re-read it.

>  caught my 'mistake' and corrected it.   And what is this high and
>  mighty remark?   I was just answering the question and trying to be

Perhaps I mis-interpreted your "Very simple.  Very easy to understand."
statement.  What I saw was one post asking for help, a half dozen or so
posts giving incorrect / partially correct information, and among all of
this confusion your (incorrect) post saying that it was "Very simple."
and "Very easy to understand."

I probably let my frustration get the best of me, and as a result I
over-reacted.  I concede that the comment was inappropriate, and for that
I apologize.  As for the factual content, I stand by my original post.


-Steve

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamspammitvma.mit.edu


2001\01\26@113704 by M. Adam Davis

flavicon
face
The person who wrote this code wants to make sure that the loop won't run
if pass=0.  If pass is anything but 0, then it will run until ptrl is
equal to or greater than size.

-Adam

Oluseyi Odeinde wrote:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestspamspamspam_OUTmitvma.mit.edu


2001\01\26@114113 by Michael Rigby-Jones

flavicon
face
> -----Original Message-----
> From: Oluseyi Odeinde [SMTP:seyiRemoveMEspamOCEAN.CF.AC.UK]
> Sent: Friday, January 26, 2001 1:54 PM
> To:   EraseMEPICLISTSTOPspamspamRemoveMEMITVMA.MIT.EDU
> Subject:      Re: [OT]: quick question on C
>
> come to think of it, after taking a 2nd look at that statement - i think
> it
> really means:
>
>  for (pass=rx_str[ptr1+1]; ptr1<size && pass=1; ptr1++) {
>
> beacuse we are dealing with a boolean AND, therefore for pass to be 'true'
> it
> must equals 1. makes sense?
>
Almost, apart from the fact that any non-zero value can be "true" in C, so
this should be:

for(pass=rx_str[ptr1+1]; ptr1<size && pass != 0; ptr1++) etc.

This is pretty nasty coding, the author of Code Complete would have a heart
attack just looking at this!  It could almost certainly be simplified by
using a while loop.

Mike

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestRemoveMEspamEraseMEmitvma.mit.edu


2001\01\26@121314 by Bill Westfield

face picon face
> > >       for (pass=rx_str[ptr1+1]; ptr1<size && pass; ptr1++) {
> > >
> > >       2. if so, is it the same as saying 'ptr1<size && ptr1<pass' ?

I think the source of the confusion is operator precedence.  The logical
operators (&&, ||) have lower precedence than math comparison, so:

a.      ptr1<size && pass

Is the same as

b.      (ptr1<size) && pass

Which is the same as

c.      (ptr<size) && (pass != 0)

While the rules are fixed and eventually decipherable, they're confusing
enough at this end of things that most code reviewer here would ask the
code to be changed to at least form "b"...

BillW

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestRemoveMEspam@spam@mitvma.mit.edu


2001\01\26@123225 by James Paul

flavicon
face
First, I believe you did over-react.

Second, My RESEND had  "*****RESEND*****UPDATED*****' all over it,
so what you responded to was not my resend, but just my second
message.

Third, it is 'very simple and easy to understand' to me.  I'm at
fault regarding this one as maybe (apparently) the asker of the
original question isn't as well versed in 'C' as you, I and others
are.  I just assumed that he would understand what I was saying.

Fourth, and please note this is not a flame, but just a question
asked calmly and sincerely.  You are you to tell me what I should
and shouldn't do with my opinion(s)?  I am a part of this list as
much as you are.  I try not to judge and repremand everyone I don't
agree with, (and sometimes there are many).  I won't say I haven't,
but I do try to control my judgements.  And once in a while, I do
jump on the soapbox and rant about something, but it isn't directed
to anyone in particular, rather everyone in general.  And now that
I think about it, I guess I'm doing what I just said you have no
right to do.   That is, I'm saying, in a roundabout way, that your
opinion about my opinion is wrong.   So forgive me too.

Just so all of you know.  I will answer a question when I believe I
have the answer to the question.   But, I do NOT CLAIM to be an
expert at PIC's or programming languages.  I believe I am well
versed enough to be able to answer a wide range of questions about
both PIC's and programming languages relating to PIC's.  But, I will
occasionally give the wrong answer.  It's inevitable.  I'm human.
So, I don't mind when I get a correction from someone (anyone).
The thing that really grinds my gears is the ones that come off
with an attitude.  So, If you have an attitude, and see that I have
answered a question wrong, check the attitude at the door, and then
send me your response as to why I'm wrong.   I will accept your
criticism for my mistake(s) without a whimper if given in the
correct tone or spirit.   Otherwise I will lend a deaf ear to them.
Is this an attitude on my part?  I don't think so.  It's a philosphy
that I try to live by, and have tried to teach my kids as as I
believe you you will get better response and acceptance by people
if you correct them in a humane and dignified manner rather than
browbeating them.  So far in my 46 years on this earth, this has
not failed.  I intend to keep believing and practicing this
philosophy for the rest of my life.  However long or short that may
be.

So with that in mind, let's just forget the whole thing ever
happened, and go on with answering the questions posted to the list.

One more thing.  I apologise to the entire list for giving any
misinformation about any question(s) that I have answered.  I'll
try to not let it happen again.


                                        Regards,

                                          Jim


On Fri, 26 January 2001, Stephen B Webb wrote:

{Quote hidden}

spamjim.....spamspamjpes.com

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspam_OUTspam@spam@mitvma.mit.edu


2001\01\26@124854 by Bill Westfield

face picon face
   for(pass=rx_str[ptr1+1]; ptr1<size && pass != 0; ptr1++) etc.

   This is pretty nasty coding, the author of Code Complete would have a
   heart attack just looking at this!  It could almost certainly be
   simplified by using a while loop.

Or even something like:

       for (pass = rx_str[ptr1+1]; ptr1<size; ptr1++) {
           if (pass == 0)
               break;

On the other hand, fragments similar to
       ((ptr < size) && string[ptr])
or      ((ptr < endptr) && *ptr)
are pretty standard in "good" C string handling code.  Bad C string
handling code doesn't check for passing the end of the string, and you
might see (ptr < end) fragments that have been tacked onto existing
for loops as "bug fixes."

BillW

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestspamspam.....mitvma.mit.edu


2001\01\26@174536 by Bob Ammerman

picon face
Actually, I think the 'pass' is a byte count grabbed from the early part of
the buffer.

When we saw the full loop there was an interesting "--pass" somewhere in it.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2001\01\27@010538 by Alok Dubey

flavicon
face
exactly.. this was the  reason why the code appeared wierd
alok


{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\27@010926 by Alok Dubey

flavicon
face
my mistake .. i assumed that the < expr was evaluated after the && sorry :-)
alok


> {Original Message removed}

2001\01\27@010945 by Alok Dubey

flavicon
face
nope.. the 1st result was correct..
< is evaluated before &&
alok


{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\27@011120 by Alok Dubey

flavicon
face
yup my mistake
:-)
alok


{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\27@011555 by Alok Dubey

flavicon
face
even pointers?
as long as not NULL?.. i never used that.. thanks
alok


{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\27@042530 by Peter L. Peres

picon face
The for() control statement has the syntax:

for '(' <expr1> ';' <expr2> ';' <expr3> ')' ( '{' <block> '}' | <expr4> ';' )

Each expr can be any valid C expression, as complex as you like. Many
books on C omit to state this clearly. Similar things apply to the other
control statements.

Peter

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...