Hi, I'm using C Comipler V7.10, Vision2 V2.40 with AT89C51SND1C micro. For my program I want to have an array for Names. I know I can do it the following way: unsigned char Names[10][10]; // 10 names, each 10 char and then use 2 "for" loops to enter in the char into the particular name, but what I want to know is, if I can do the following: typedef unsigned char NAME_LEN[10]; NAME_LEN Name[10]; void main() { Name[0]="FOO"; // First name is FOO } I'm getting the following error "left side of asn-op not a lvalue". Why is the above code not vaild? Thanks
because writing "FOO" in 'C' is equivalent to witing the address of the 1st character of the string - but you you want an array of characters. The 'C' programming language does not allow you to copy an entire array in a single assignment (you can do it with structures, but not arrays). To copy an array you need to write a for loop, or use memcpy(), etc.