One thing I enjoy when I'm bored is toying with the teaching assistants. A friend of mine discovered that he could free a variable and immediately access it (this is ANSI C) and the program worked, but seqfaulted immediately after giving the intended result. He turned this in.. the TA never noticed.
My favorite is the so-called "void pointer" program. It goes something like this:
1. Initialize a pointer of type void to NULL. Yes, this is allowed.
2. calloc a big block of memory. If you need more, just reallocate.
3. Any time you need to store something, just move the pointer to the appropriate spot, typecast the pointer, and suck the data out. Ditto for loads.
4. At the end of the program, free the block of memory, and then for effect, point the pointer at itself and dealloc the pointer variable.
Unfortunately, the program I was writing using this technique was mathematical in nature, and the corresponding explosion of typecasts was WAY too much to deal with.
Oh well, it would have been too confusing for me, anyway.
Thank you for this opportunity, Dr. Lederman. From what I have heard, the SSC project was cancelled due to excessive cost, and the attitude that "this money could be put to better use". My question is this: Given that the cost of serious scientific research is rather high, results may be years in coming, and often, the research done at accelerator facilities does not appear to have any impact on the life of the average person, many people do not see the use of such expensive research facilities. Thus, many worthy projects (the SSC, for one.) never get built or suffer budget and funding cuts. What is the best way to convince "the powers that be" that the work done at these labs justifies the cost?
One thing I enjoy when I'm bored is toying with the teaching assistants. A friend of mine discovered that he could free a variable and immediately access it (this is ANSI C) and the program worked, but seqfaulted immediately after giving the intended result. He turned this in.. the TA never noticed.
My favorite is the so-called "void pointer" program. It goes something like this:
1. Initialize a pointer of type void to NULL. Yes, this is allowed.
2. calloc a big block of memory. If you need more, just reallocate.
3. Any time you need to store something, just move the pointer to the appropriate spot, typecast the pointer, and suck the data out. Ditto for loads.
4. At the end of the program, free the block of memory, and then for effect, point the pointer at itself and dealloc the pointer variable.
Unfortunately, the program I was writing using this technique was mathematical in nature, and the corresponding explosion of typecasts was WAY too much to deal with.
Oh well, it would have been too confusing for me, anyway.
Jason
Thank you for this opportunity, Dr. Lederman. From what I have heard, the SSC project was cancelled due to excessive cost, and the attitude that "this money could be put to better use". My question is this: Given that the cost of serious scientific research is rather high, results may be years in coming, and often, the research done at accelerator facilities does not appear to have any impact on the life of the average person, many people do not see the use of such expensive research facilities. Thus, many worthy projects (the SSC, for one.) never get built or suffer budget and funding cuts. What is the best way to convince "the powers that be" that the work done at these labs justifies the cost?