-
November 7th, 2002, 02:18 PM
#1
--index or index--
quick question...prolly a fast answer but here goes...why would code be this:
Code:
buffer[index - bufIndex] = '\0';
--index;
instead of:
Code:
buffer[index-- - bufIndex] = '\0';
because my understanding is that the later is the same thing as the first...
thanks for the help
- nc
"In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
"What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
"Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur
Live Penguine! - Tux the linux mascot
Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!
-
November 7th, 2002, 02:37 PM
#2
Just some thoughts:
I myself tend to put those things on several lines, for readability and for debugging purposes.
Now you can put a breakpoint on each line, or watch more closely what happens.
The compiler optimizes these things anyway (if you want), so there is no performance problem anyhow.
This is not a to difficult thing, but i've seen monsters of expressions that would take me a long time to figure out. Mostly had to take a look at them because they where wrong!!
i'm also in the habbit of using a lot of parenthesis, such that i'm really sure that the operators are evaluated exactly the way i want.
I once read (at school still, i think) that operator precedence is dependent on the compiler. Therefor i make sure the statement will be always evaluated the same.
Hope this clears it up a bit,
Steven Roelants
-
November 7th, 2002, 02:37 PM
#3
Yep they do the same thing.
-
November 7th, 2002, 02:42 PM
#4
ok thats what i thought and i figured that it was set up that way for readability but i'm a java programmer now and i'm teaching myself VC++/C++/C with some breif knowledge of ASM and my knowledge of Java it's made my transition MUCH easier but i want to be sure that things will do the same thing...
You are right about the parens thing as well...i use parens all the time specially with C++ and pointers<crucial to>
anyway...
thanks for the help
- nc
"In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
"What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
"Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur
Live Penguine! - Tux the linux mascot
Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|