Lesson 19 of 23
Call by Reference: Swap
9 min 35 XP
Function-க்கு variable-ன் address-ஐ அனுப்பினால், function அந்த variable-ஐயே மாற்ற முடியும். scanf(&x) இப்படித்தான் வேலை செய்கிறது. பல மதிப்புகளைத் திருப்பித் தரவும் இதுவே வழி.
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.Array-ஐ function-க்கு அனுப்பும்போது அதன் முதல் உறுப்பின் address தான் போகிறது. ஆகவே function array-ஐ மாற்றினால் main-லும் மாறும்.