DEV Community

PC Yang
PC Yang

Posted on

[菜雞刷題日記] x++ 與++x 的差別?其實很容易懂!

剛開始寫C++就遇到了此問題,可能對很多人來說是簡單到不行的問題,但實際使用才發現自己對兩者差異不是很熟

許多大神的解釋過於艱深,我實在難以理解(我的問題)

然而,其實用一個例子就能懂,什麼是

X++ is post increment and ++x is pre increment.

舉例:

For ++x

Image description

Output: 6,6

For x++

Image description

Output: 5,6

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay