Home AMX User Forum AMXForums Archive Threads Tips and Tricks
Options

Questions about char arrays as constants

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

  • Options
    Joe HebertJoe Hebert Posts: 2,159
    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
  • Options
    dspotdspot Posts: 23
    Thanks a lot
Sign In or Register to comment.