Header file and extern keyword

前端 未结 5 2047
青春惊慌失措
青春惊慌失措 2021-01-22 21:06

I am having a lot of issue using extern variable and header files. I have read through sections of books and searched the web for hours but I haven\'t been able to figure out. A

5条回答
  •  孤街浪徒
    2021-01-22 21:32

    An external variable must be defined, exactly once, outside of any function; this sets aside storage for it. The variable must also be declared in each function that wants to access it;

    check this link. well explained How do I use extern to share variables between source files?

提交回复
热议问题