Create extern char array in C

后端 未结 4 762
春和景丽
春和景丽 2020-12-09 17:09

How to create an external character array in C?

I have tried various ways to define char cmdval[128] but it always says undefined reference to \'

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 17:54

    You should have a compilation unit in which you define the cmdval variable. The extern keyword only declares that the variable exists, it does not define it.

    Put the following line in first.c, second.c or in an other C file of your choice:

    char cmdval[128];
    

提交回复
热议问题