K
Keith Thompson
Malcolm said: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.
Malcolm said:It's not associative
a = INT_MAX;
b = 1;
c = -1;
(a + b) + c;
and
a + (b + c);
won't necessarily be the same.
Daniel Rudy said:At about the time of 12/31/2005 11:27 AM, pemo stated the following: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.
What is that --_ in the for initializer?pemo said:At about the time of 12/31/2005 11:27 AM, pemo stated the following:
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 said:[snip]pemo said:Daniel Rudy said:At about the time of 12/31/2005 11:27 AM, pemo stated the following:
main(_){for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1);}
What is that --_ in the for initializer?
Keith said:Red Cent said:[snip]pemo said:At about the time of 12/31/2005 11:27 AM, pemo stated the following:
main(_){for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1);}
What is that --_ in the for initializer?
_ is an identifier. -- is the predecrement operator.
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)
Not so much treat argv as an int, but typecast it to another variable
if needed (as a number)
Kenneth Brody said:(See the numerous other posts about properly quote using Google Groups.)
Why in the world would you treat argv as an int?
Keith said:I knew that only because I happened to read your response immediately
after Kenneth's article. Please read <http://cfaj.freeshell.org/google/>
and follow its advice *before* you post here again; it's important.
If you're talking about something like interpreting the string pointed
to by argv as an integer, such as the string "123", that's not
typecasting (or, more properly, casting).
Red Cent said:Keith Thompson writes: [snip]If you're talking about something like interpreting the string pointed
to by argv as an integer, such as the string "123", that's not
typecasting (or, more properly, casting).
I neglected to mention that I might cast one of the members of the
array.
If it's not casting, what is it? Converting?
I have no idea how this came up, due to the total lack of context>
Not so much treat argv as an int, but typecast it to another
variable if needed (as a number)
Keith said:Can you provide an example, in C code, of what you're talking about?
Red Cent said:(in reference to casting a string to an int)
Off the top of my head, I can't remember when I've used this. Vaguely
I remember having a program that needed to run X number of times. So I
passed an argument "123" which main's argv got.
Now in order to run it that many times, I needed to cast "123" to an
int 123, so I could use it in a counting loop.
At about the time of 12/31/2005 11:27 AM, pemo stated the following:
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?
Daniel Rudy said:At about the time of 1/3/2006 3:48 AM, pemo stated the following:
At about the time of 12/31/2005 11:27 AM, pemo stated the following:
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?
Who ever wrote that code. Granted, I'm fairly new to C myself, so I
could be considered a wannabe...But you will not catch me coding like
that.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.