Inititalising a char array from multiple sources

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Xzyx987X

    Inititalising a char array from multiple sources

    I wanted to do something like this: const char reg_defaultKey[30] =
    {REG_DEFPATH, "\\" , VERSION};
    What is the proper syntax? The above was just my best guess but it didn't
    work and I couldn't find any info on the correct way anywhere else.


  • Malcolm

    #2
    Re: Inititalising a char array from multiple sources


    "Xzyx987X" <Xzyx987X@mn.rr .com> wrote[color=blue]
    > I wanted to do something like this: const char reg_defaultKey[30] =
    > {REG_DEFPATH, "\\" , VERSION};
    > What is the proper syntax? The above was just my best guess but it didn't
    > work and I couldn't find any info on the correct way anywhere else.
    >[/color]
    #define REGPATH "C:\\MyRegistry Path"
    #define VERSION "1.0"

    const char reg_defaultKey[30] = REGPATH "\\" VERSION;

    The strings concatenate, so "hello " "world" is the equivalent to "Hello
    World".

    If VERSION is a number rather than a string, you need to use the
    "stringizer ", which is a #, to convert the number into a string.


    Comment

    Working...