Is there a macro that can get a text as input like "abc" and then extract characters in that text and generate a code using them, something like "{'a','b','c'}" ?
thanks.

Recommended Answers

All 4 Replies

Not a macro, but you can easily write a function to do that. Give it a try and see what you can gome up with.

Ancient Dragon

Not a macro, but you can easily write a function to do that. Give it a try and see what you can gome up with.

Actually i'm talking about preprocessing here, so what does a function have to do with preprocessing ?

I'm not a mind reader nor am I clairvoyant.

Well look at Boost::Preprocessor, if there isn't a way to do this with that library, there is no way to do it period. There is BOOST_PP_STRINGIFY which takes a non-literal string like just abc and turns it into a literal string "abc". There might be other things of that flavour and that would somehow achieve what you desire.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.