Inititalising a char array from multiple sources

X

Xzyx987X

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.
 
M

Malcolm

Xzyx987X said:
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.
#define REGPATH "C:\\MyRegistryPath"
#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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top