This topic has been archived. It cannot be replied.
工作学习 / IT杂谈 / C++ help, simple question
-bluewave(tony);
2001-12-7{241}(#289302@0)
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
-clinux(C/Linux);
2001-12-7(#289369@0)
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,
-bluewave(tony);
2001-12-8(#290358@0)
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.
-clinux(C/Linux);
2001-12-8(#290752@0)
thank you very much
-bluewave(tony);
2001-12-10(#292266@0)
static means global. Hehe. You can define it as static
-bugkiller(bugkiller);
2001-12-27(#314304@0)