How do I share variables between different .c files? -


इस सवाल का पहले से ही एक उत्तर है: < 14 जवाब

सी घोषणा के बारे में शुरुआती प्रश्न: / p>

  • एक। सी फ़ाइल में, किसी अन्य। सी फाइल में परिभाषित चर का कैसे उपयोग करें?

फ़ाइल ए में:

  int myGlobal = 0;  

में fileA.h

  extern int myGlobal;  

में fileB.c:

  #include "fileA.h" myGlobal = 1;  

तो यह कैसे काम करता है:

  • fileA.c में चर रहता है
  • fileA.h दुनिया को बताता है कि यह मौजूद है, और इसका क्या प्रकार है ( int )
  • fileB.c में fileA.h भी शामिल है, ताकि कंपाइलर myBlobal के बारे में जानता है इससे पहले कि fileB.c इसका उपयोग करने की कोशिश करता है।

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -