ProAnswers.org

why this is not working?

I had the definition char x[6] in one source file, and in another I declared extern char *x. Why didn’t it work?

Hi Daniel,

The declaration extern char *x simply does not match the actual definition. The type “pointer-to-type-T” is not the same as “array-of-type-T.” Use extern char x[].

References: CT&P Sec. 3.3 pp. 33-4, Sec. 4.5 pp. 64-5.