Questions about char arrays as constants

dspotdspot Junior MemberPosts: 23
I defined this in my code:
DEFINE_CONSTANT
char cSome[12]	= "'E0A',$02,'02D30002'"

and found an error in compiling
ERROR: d:\jobs\research\testing.axs(83): C10583: Too many elements in initializer  

So, what I did was just to omit the 12 so it becomes cSome[].

When I did a send_command like
SEND_COMMAND dvTV,"'PASSTHRU-',cSome"

and looking into the diagnostic window, it seems that the quotes are also sent. What am I doing wrong?

Comments

  • Joe HebertJoe Hebert Junior Member Posts: 2,154
    TN 531
    dspot wrote: »
    I defined this in my code:
    DEFINE_CONSTANT
    char cSome[12]	= "'E0A',$02,'02D30002'"
    

    and found an error in compiling
    ERROR: d:\jobs\research\testing.axs(83): C10583: Too many elements in initializer  
    

    So, what I did was just to omit the 12 so it becomes cSome[].

    When I did a send_command like
    SEND_COMMAND dvTV,"'PASSTHRU-',cSome"
    

    and looking into the diagnostic window, it seems that the quotes are also sent. What am I doing wrong?

    Try this:
    DEFINE_CONSTANT
    char cSome[]	= {'E','0','A',$02,'0','2','D','3','0','0','0','2'}
    

    For an explanation check out Tech Note 531: How to Initialize Character Strings in the DEFINE_CONSTANT and DEFINE_VARIABLE Sections
  • dspotdspot Junior Member Posts: 23
Sign In or Register to comment.