luck, db
There are no new questions, but there may be new answers.
That wasn't clear. Sorry. I didn't mean your code, but different code compiled by three compilers giving different results.I earlier wrote: . . . I have seen different results from different C compiler for the same code in the past . . .
var2=var2 || var1++ && printf("Computer World");
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
A nice demonstrationAndrew Monkhouse wrote: . . . you may want to do a simple test on your own compiler . . .
Jatin sachdev wrote:If we go by the precedence rules of C then var1++ will be executed first then && and || in the last.
But the compiler is executing || first.
Why???
Jatin sachdev wrote:and one more thing in expressions like this :
2+3*4+9
compiler follows precedence because it first calculates * then +.
Jatin sachdev wrote:The main problem with C is its compiler is not very strict.
Jatin sachdev wrote:It is not strictly typed language.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Andrew Monkhouse wrote:
Jatin sachdev wrote:It is not strictly typed language.
True - the fact that we use an integer as a boolean, and later use the boolean result as an integer is very loose typing. Some C aficionados would claim this is a benefit - certainly I have seen some "interesting" code that would not have worked without that feature. Quite often structs are a prime example of this.
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
Anand Hariharan wrote:
Could you clarify what you mean by this in "Quite often structs are a prime example of this"?Andrew Monkhouse wrote:
True - the fact that we use an integer as a boolean, and later use the boolean result as an integer is very loose typing. Some C aficionados would claim this is a benefit - certainly I have seen some "interesting" code that would not have worked without that feature. Quite often structs are a prime example of this.Jatin sachdev wrote:It is not strictly typed language.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Jatin sachdev wrote:Thank you for your reply Andrew Monkhouse.....
I think I have to first learn the "PRINCIPLES OF PROGRAMMING LANGUAGES"
How about the book Terrence Pratt, Marvin Zelkowitz??
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
It was overcast here every night, so I didn't see anything.Andrew Monkhouse wrote: . . . staying up until midnight to see the meteor shower . . .
Andrew Monkhouse wrote:What I was thinking of was a union of structs. The unions are so simplistic that I rarely even think of them while thinking about the real problem that I am trying to solve. However the structs themselves can have completely different internal data types. And it is this overlaying of the structs in the same memory region, and the automatic type conversions that happen, that is what I was thinking about.
Andrew Monkhouse wrote:
Campbell Ritchie wrote:And unions are probably more confusing than pointers. Probably written for economy, in the days when 2kB was a lot of memory.
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
Consider Paul's rocket mass heater. |