Velocity Reviews > How to understand this line of c ?

# How to understand this line of c ?

Keith Thompson
Guest
Posts: n/a

 01-03-2006
"Malcolm" <(E-Mail Removed)> writes:
> "Keith Thompson" <(E-Mail Removed)> wrote
>> When is "+" non-commutative in C (ignoring the unary "+" operator)? I
>> can't think of any cases where a+b and b+a have different meanings.
>> They might yield different results in some cases due to unspecified or
>> implementation-defined behavior, but in all such cases there's no
>> consistent difference between a+b and b+a.
>>

> It's not associative
>
> a = INT_MAX;
> b = 1;
> c = -1;
>
> (a + b) + c;
> and
> a + (b + c);
>
> won't necessarily be the same.

Ok, but we were talking about commutativity, not associatativy.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.

pemo
Guest
Posts: n/a

 01-03-2006

"Daniel Rudy" <(E-Mail Removed)> wrote in message
news:aHiuf.5705\$(E-Mail Removed) ...
> At about the time of 12/31/2005 11:27 AM, pemo stated the following:
>> "lnzju" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) oups.com...
>>
>>>main(_){for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1);}

>>
>>
>> Here it is a little clearer [hopefully?]
>>
>> #include <stdio.h>
>>
>> // x will be 1 (the name of this app would be in argv[0]) if we
>> // don't invoke the app with some args.
>> //
>> main(x)
>> {
>> char c;
>>
>> // zero then!
>> //
>> --x;
>>
>> while(c = "J!Mpwf!Zpv\1"[x])
>> {
>> // No need for the -1 if we add 1 to the literal's characters...
>> //
>> // "I Love You\1"
>> //
>> c = c - 1;
>>
>> x++;
>>
>> putchar(c);
>> }
>> }
>>
>>

>
> You know, the code that the OP provided is the reason why I hate
> wannabe's trying to be hack programmers to impress the rest of us.
> Anyone who codes like that needs to be shot, not once, not twice, but
> thrice. Perferably in the groin.

wannabes - who, me, them, you?

Red Cent
Guest
Posts: n/a

 01-04-2006
pemo wrote:
> "Daniel Rudy" <(E-Mail Removed)> wrote in message
> news:aHiuf.5705\$(E-Mail Removed) ...
>
>>At about the time of 12/31/2005 11:27 AM, pemo stated the following:
>>
>>>"lnzju" <(E-Mail Removed)> wrote in message
>>>news:(E-Mail Removed) egroups.com...
>>>
>>>
>>>>main(_){for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1);}
>>>
>>>
>>>Here it is a little clearer [hopefully?]
>>>
>>>#include <stdio.h>
>>>
>>>// x will be 1 (the name of this app would be in argv[0]) if we
>>>// don't invoke the app with some args.
>>>//
>>>main(x)
>>>{
>>> char c;
>>>
>>> // zero then!
>>> //
>>> --x;
>>>
>>> while(c = "J!Mpwf!Zpv\1"[x])
>>> {
>>> // No need for the -1 if we add 1 to the literal's characters...
>>> //
>>> // "I Love You\1"
>>> //
>>> c = c - 1;
>>>
>>> x++;
>>>
>>> putchar(c);
>>> }
>>>}
>>>
>>>

>>
>>You know, the code that the OP provided is the reason why I hate
>>wannabe's trying to be hack programmers to impress the rest of us.
>>Anyone who codes like that needs to be shot, not once, not twice, but
>>thrice. Perferably in the groin.

>
>
> wannabes - who, me, them, you?
>
>

What is that --_ in the for initializer?

Keith Thompson
Guest
Posts: n/a

 01-04-2006
Red Cent <(E-Mail Removed)> writes:
> pemo wrote:
>> "Daniel Rudy" <(E-Mail Removed)> wrote in message
>> news:aHiuf.5705\$(E-Mail Removed) ...
>>>At about the time of 12/31/2005 11:27 AM, pemo stated the following:
>>>>"lnzju" <(E-Mail Removed)> wrote in message
>>>>news:(E-Mail Removed) legroups.com...
>>>>
>>>>>main(_){for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1);}

[snip]

> What is that --_ in the for initializer?

_ is an identifier. -- is the predecrement operator.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <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.

Red Cent
Guest
Posts: n/a

 01-04-2006
Keith Thompson wrote:
> Red Cent <(E-Mail Removed)> writes:
>
>>pemo wrote:
>>
>>>"Daniel Rudy" <(E-Mail Removed)> wrote in message
>>>news:aHiuf.5705\$(E-Mail Removed). net...
>>>
>>>>At about the time of 12/31/2005 11:27 AM, pemo stated the following:
>>>>
>>>>>"lnzju" <(E-Mail Removed)> wrote in message
>>>>>news:(E-Mail Removed) glegroups.com...
>>>>>
>>>>>
>>>>>>main(_){for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1);}

>
> [snip]
>
>
>>What is that --_ in the for initializer?

>
>
> _ is an identifier. -- is the predecrement operator.
>

Duh.... That's what I get for posting before looking at the entire

Xiaocao Feidao
Guest
Posts: n/a

 01-04-2006
_ can be the name of a variable. Yes, _ is a legal varible name for C.
Thanks to tmp123!

truthgrepper@sbcglobal.net
Guest
Posts: n/a

 01-04-2006
My usual problem with using argv is I forget it's an array of strings.
I either forget to cast to an int if I need it or forget to use **argv
(pointers to pointers)

Kenneth Brody
Guest
Posts: n/a

 01-04-2006
(E-Mail Removed) wrote:
>
> My usual problem with using argv is I forget it's an array of strings.
> I either forget to cast to an int if I need it or forget to use **argv
> (pointers to pointers)

Why in the world would you treat argv as an int?

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <(E-Mail Removed)>

truthgrepper@sbcglobal.net
Guest
Posts: n/a

 01-04-2006
Not so much treat argv as an int, but typecast it to another variable
if needed (as a number)

Keith Thompson
Guest
Posts: n/a

 01-04-2006
(E-Mail Removed) writes:
> Not so much treat argv as an int, but typecast it to another variable
> if needed (as a number)

This was in response to:

Kenneth Brody <(E-Mail Removed)> writes:
> (See the numerous other posts about properly quote using Google Groups.)
>
> Why in the world would you treat argv as an int?

I knew that only because I happened to read your response immediately

argv is of type char**. I can't think of any circumstances in which
it would make sense to cast it to int (i.e., (int)argv). Can you show
us an example of what you're talking about?

If you're talking about something like interpreting the string pointed
to by argv[i] as an integer, such as the string "123", that's not
typecasting (or, more properly, casting).

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <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.