There are always few little known or hidden features in each programming language. At StackOverflow.com someone started a series of posts “Hidden features of” programming languages. The Hidden Features series is great for people who are new to a certain language.

I have collected few of the features of both C and C++ here.

Like the ternary operator; most of the programmers are familiar with.

However this can be used the other way.
(y < 0 ? x : y) = 20;
It means the following.

Another feature is Resource Acquisition Is Initialization (RAII) which is often ignored by the programmers coming from non object oriented world i.e. C programming background.

Can you write a return statement in a function that returns void?

Even you could write something like

The comma operator isn’t widely used. It can certainly be abused, but it can also be very useful. One of the most common use is

Elon Musk
Discover the mind behind the innovations – Elon Musk by Walter Isaacson, now on Audible. Dive into the life of a visionary shaping our future!
View on Amazon

C99 has some awesome any-order structure initialization.