473,416 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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 3017
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
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...
8
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...
2
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...
7
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...
3
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"...
18
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?...
1
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....
28
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
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.