×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT杂谈 / C++ help, simple question
    please help although basic,
    I want to modify a varaible type int in different c(or c++) souece, s1.c s2.c,
    how can I define this variable, static? or anyothers, where to define,
    I am really new to this field,

    Thanks in advance,

    tony
    • define it in s1.c as a global variable, i.e. in the very beginning before any functions. in s2.c, define "extern int xxx", then you can modify it in s2.c
      • Thanks C/linux, Can I define it inside .h file or one of .c file? do I need to define it as static or something else for I want it to be static,
        • Usually, you should define it in .c file. But don't define it as static, cause static means it is only visible inside this file.
          • thank you very much
            • static means global. Hehe. You can define it as static