Is there way to split a string or otherwise, get each character of a string using a macro?
1 2 3
|
#define macro(x) '#x[0]', '#x[1]'
macro( somestring )
|
Either to put in a character array or to use in as parameters, whatever.
Last edited on
You can get the characters of a C++ string with the
[]
operator.
For example,
1 2
|
char firstChar = somestring[0];
char fifteenthChar = somestring[14];
|
What do you want instead?
Last edited on
Well rather than having to type:
's', 'o', 'm', 'e', 's', 't', 'r', 'i', 'n', 'g'
I was wondering if there was a way to split text into that manner using the preprocessor.