Difference between "char *arr" and "char arr[]"
    Frank [Who me?] Kuan 
    kuan at iris.ucdavis.edu
       
    Sat Sep 22 13:23:35 AEST 1990
    
    
  
In file "a.c", I declare:
char targ[128];
In file "b.c" I do:
extern char *targ;
Result: I got massive errors. When I source debugged it, it told me
that the char pointer "targ" was 0x000000. 
By chance, I tried redeclaring it as "extern char targ[]" and
the problem was fixed.
Now, I always thought that "targ[]" and "char *targ" were equivalent.
I have several places in my program where I use those two notations
interchangeably, and this was the first time I've ever had a problem
with it. 
Could a C wizard explain to me what I'm doing wrong and what the
correct practice is so I don't run into these horrible bugs again?
Thanks in advance.
- f
    
    
More information about the Comp.lang.c
mailing list