c - Scope and lifetime of a variable -


संभव डुप्लिकेट:

सी में एक चर के दायरे और जीवनकाल के बीच अंतर क्या है? फ़ंक्शन के अंदर एक ब्लॉक के भीतर घोषित एक चर का दायरा और जीवनकाल क्या है?

चलिए कहते हैं कि हमारे पास दो कार्य हैं:

  void foo () {/ * कुछ सामान * /} शून्य बार () {int local_bar; foo (); फ़ंक्शन  बार  में वेरिएबल  local_bar  के दायरे में फ़ंक्शन के अंदर कुछ अधिक सामान * /}   

करें < कोड> बार foo को कॉल करते समय चर अस्थायी रूप से दायरे से बाहर हो जाता है, यानी यह foo के अंदर से उपलब्ध नहीं है हालांकि, चर का जीवनकाल समाप्त नहीं हुआ है, यह केवल तभी खत्म होगा जब फ़ंक्शन बार समाप्त होता है।

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -