Stringify C preprocess

后端 未结 1 463
小鲜肉
小鲜肉 2020-12-18 12:14

This is my first post, so if I\'m being too vague or giving information that everyone would intuitively assume, please let me know.

I\'m very new to writing in

相关标签:
1条回答
  • 2020-12-18 12:54

    To stringify a #define you need to use a two-step approach:

    #define _STRINGIFY(s) #s
    #define STRINGIFY(s) _STRINGIFY(s)
    
    ...
    
    #define SEED 123
    
    ...
    
    const char * pszSeed = STRINGIFY(SEED); /* 'pszSeed' would point to "123" form here on. */
    

    If you only want to use one character simply access it via *pszSeed or pszSeed[0].

    0 讨论(0)
提交回复
热议问题