Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me decyper this piece of code 1

Status
Not open for further replies.

hkarameh

Programmer
Feb 9, 2007
5
US
I am beginner and I need some help:

XXX is far pointer to structure SS
there is a test
if (!XXX) ...

what '!XXX' is testing for?
XXX not being null?
the first element of SS not being null,false or ?
 
So just to be sure
if(!XXX)

is the same as : if (XXX==NULL)
Correct?

BTW, thankx for quick answer
 
... and once again many congratulations to the person who wrote the original code, for saving themselves 5 key-strokes. It's good to know that the traditions of readability in C are being kept alive.

 
Sometimes I think C is for cutesy code some programmers write. With non-optimizing compilers and slow processors, there MAY have been some advantage in the past to writing this kind of stuff, but since 1991 I've found writing clear code to be better than more obscure code.

Lee
 
I do not blame the original author. He has gone long way from 8bit uP ASM coding and finally 'graduated' on C.
As I hear he has been happily retired for 10 years.
 
It may also depend on when the program was written. Many earlier compilers did not optimize their code, that was left up to the programmer. This meant that coding like that above was recommended or the program could be too big for the compiler or OS to use.

I used to have a DOS compiler that when if you used comments, it would increase the size of the executable. The more comments, the bigger the program. I had to write another program that would remove the comments before the compiler ran or the program was too big for DOS to run.

I once read where a whole program written in the second option of a for loop in order for the compiler to "compress" the program.

Code:
for (int x = 0; (whole program here); x = x+1)





James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Have you ever looked in the executable file to see if the comments are inside the code somehow?

Your for loop above. If the main program is really inside it, it should have been written using the comma operator. There's nothing compact about that because the compiler generates more machine code for comma operators than commands separated by semicolons.
 
You have to remember these were done 30 years ago. The standards hadn't even been set up yet. Every compiler maker did something different. Most of those companies have long since gone or been bought by other companies. Heck, some of the OS aren't even around, anymore. :)



James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
You have to remember these were done 30 years ago. The standards hadn't even been set up yet. Every compiler maker did something different. Most of those companies have long since gone or been bought by other companies. Heck, some of the OS aren't even around, anymore.

Hurrah to all of that...
 
OK, OK I apologise! Yes, I remember writing basic on an Acorn Atom with 0.5K memory too... (managed to squeeze moonlander into 256 bytes once; dreadful to play, but it did more-or-less work).


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top