473,561 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Beginner post-increment question

The following statement:

line_buf[line_len++] = ' ';
is equivalent to:

line_buf[line_len] = ' ';
line_len++;

because post-increments are done AFTER the non-incremented values are
used in the statement.
Correct?
Jan 15 '08 #1
3 3024
yes, it's correct but note that you should avoid to:

1) use the increment or decrement operators on a variable that appears
more than once in an expression

For example avoid using constructs like the following

n = 1;
y = n++ + n++;

2) use the increment or decrement operators on a variable that is part
of more than one argument of a function

Example to avoid

printf("%d %d\n", number, number*number++ );

The reason is because the second argument might be evaluated before
the first one
Jan 15 '08 #2


DiAvOl wrote:
yes, it's correct but note that you should avoid to:

1) use the increment or decrement operators on a variable that appears
more than once in an expression

For example avoid using constructs like the following

n = 1;
y = n++ + n++;

2) use the increment or decrement operators on a variable that is part
of more than one argument of a function

Example to avoid

printf("%d %d\n", number, number*number++ );

The reason is because the second argument might be evaluated before
the first one
You forgot the one thing to avoid:

3) Never use pre or post increment as parameters to macros, as a macro
might use the parameter more than once. As a consequence, item 2
should be "never use increment or decrement on parameters to a
function", as you might not know if this is a real function, or that
this was implemented as a macro.

Kind regards,
Johan Borkhuis
Jan 15 '08 #3
Flash Gordon wrote:
>
.... snip ...
>
implementation is *not* free to feed your mother to the
ravenous bug blatter beast of traal.
Ahh. That explains many of my problems. :-)

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 16 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2192
by: Rod Carrol | last post by:
Hello all, As a beginner I've been exeperiencing lots of errors while building my website, (I'm currently attempting to implement a member login/registration piece for my site using mySQL and PHP) I've read that PHP is secure in that it hides lots of code from hackers and people trying to snoop around on the web site running the PHP...
8
2108
by: Raghuraman | last post by:
Hai ! I use the Grid control with the data environment and the recordset control by dragging from the data env. But if i run the page alone in the iexplorer it tells the error like pm.script liabrary not found even though i open it in the scripting libraries.
2
2017
by: Zipper | last post by:
Hello, this is my first time posting to this newsgroup, I was unable to find the FAQ for this group. I'm not sure where it's web presence is, but I was hoping someone might be able to point me in the direction of a good beginner Windows programming book. I have a decent understanding of C++ (not great but good enough that I can work through...
7
2916
by: Rensjuh | last post by:
Hello, does someone have / know a good C++ tutorial for beginnners? I would prefer Dutch, but English is also fine. Hoi, heeft / kent iemand nog een goede C++ tutorial voor beginners? Het liefste in Nederlands, maar Engels is ook goed. Thnx, Rensjuh
3
1617
by: Chung Hang Shum | last post by:
I'm a beginner in ASP.Net. I'd wroten mange asp code before and now I need to transfer them from asp to asp.Net. In classical ASP you can write code like this: <% If strRequest = "ConfirmPasswd" then%> <TABLE border="0" class="ContentArea" width="100%"> <TR><TD>Change Password?</TD></TR> </TABLE> <TABLE border="0" cellPadding="2"...
18
2904
by: mitchellpal | last post by:
Hi guys, am learning c as a beginner language and am finding it rough especially with pointers and data files. What do you think, am i being too pessimistic or thats how it happens for a beginner? Are there better languages than c for a beginner? For instance visual basic or i should just keep the confidence of improving?
1
1780
by: Blue_hatter | last post by:
Hey Guys, I'm a newbie to the whole C++ Programming thing as I think I said before in a post. The thing is, I have this idea that might help me to learn at a better pace than I am doing currently. I realise that I learn better if I explain things as I go along. My suggestion is, I start a tutorial as I learn the concepts of the language from...
28
2255
by: angeluslii | last post by:
Which IDE would you recommend for a beginner doing C programming possibly one which would work with Windows Vista and does syntax highlighting?
22
18114
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php programmer and looking for a starting point in regards to practical projects to work on. What are some projects that beginner programmers usually...
0
7637
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8072
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7924
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6195
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5177
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1171
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
884
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.