|
Thank you, Bill! But may I ask, it was "frightening" in the sense of?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Afzaal Ahmad Zeeshan wrote: "frightening" in the sense of? I'd say it's about the same way as I feel looking in a mirror: that sense that what is on the surface is a very bad cover-up of something strange, and probably up to no good
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Well, learning C at this era is also upto no good. But, it is worth a shot. Using your example, I would be much more interested in the "man inside" rather than the bad cover-up.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Interesting - actually neat - but it would fail, I think if stretched a bit:
int x=5;
a[x] != x[a];
But your discovery is truly wondrous!
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Seems to work fine.
#include <iostream>
int foo(int x, int *a)
{
return x[a];
}
int main()
{
int arr[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int x = 5;
std::cout << arr[x] << " "
<< x[arr] << " "
<< foo(x, arr) << std::endl;
}
Compiles and runs as expected without warning.
|
|
|
|
|
That's unfortunate - I was hoping that the compiler wouldn't accept it because it makes x appear to be an array.
It's not that I don't understand - but one could hope that the compiler would differentiate between the two.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
The compiler doesn't do a + 5 , it is worse than that - it does a + 5 * sizeof(5) , so 5[a] becomes 5 + a * sizeof(a) , which is OK, since a is a pointer, and pointers are integers that can be added and multiplied.
Learning something new about Haskell is like buying a new clothes. Learning something new about C/C++ is like discovering the nuclear reaction - it can change you and not always for good. Please, please, don't get twisted, don't go into C/C++ land!
|
|
|
|
|
Thanks,
This was the question I used on applicants who claimed (on a scale of 1..10) a level 9 or 10 knowledge of the C language.
Also, I believe a[5] == *(a+5)
Because a[5] gives you the VALUE, not the pointer to the value
The rule as I learned it, is every [] => * level of de-referencing.
|
|
|
|
|
Here's my favorite obscure C/C++ array trick, to print hex digits.
std::uint8_t byte
char code[3] = 0;
...
code[0] = "0123456789ABCDEF"[byte >> 8];
code[1] = "0123456789ABCDEF"[byte & 0xf];
std::cout << code;
|
|
|
|
|
For the record, this behavior is part of C since K&R. It exists in C++ for backward compatibility. I am not an objective-C guy, but suspect it has same behavior.
|
|
|
|
|
I've had to use this knowledge before for an interview. They wanted me to explain how an array could be a constant lookup, and how they worked. This example is extremely good for just being able to understand how an array stores memory and how is accesses it.
|
|
|
|
|
Just looked at the paper wall-planner on the wall behind my desk to see what today's date is. I was looking for it to be highlighted
|
|
|
|
|
|
Is that one washing out after one day? Then it would be perfect.
|
|
|
|
|
When I'm looking through books, manuals or just plain printed documents there has been times when I genuinely wondered how the search function works.
It's a real pain in the derrière when you don't have access to digital copies.
|
|
|
|
|
|
I tried to copy and paste from a paper notebook a few months ago.
Some men are born mediocre, some men achieve mediocrity, and some men have mediocrity thrust upon them.
|
|
|
|
|
I was expecting you to be more like me.
Realizing you put it up there in 1998, and it did not update itself automatically!
|
|
|
|
|
My lady got into bed the other night with an actual paperback book, she began to read it then casually reached out and switched the light off!
Then she switched it back on again
|
|
|
|
|
|
Okay, i'm gonna leave work early today!
Rules for the FOSW ![ ^]
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
This highlights the fact that children are half-way between man and animal.
I never finish anyth
|
|
|
|
|
Nah...my cat can generate code. It doesn't compile, but it's better than some in QA!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Which language? Does it have problems with casing?
I never finish anyth
|
|
|
|
|
Looks like APL[^] to me...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|