<p>I'm looking for a way to convert a preprocessor token to a string.</p>

<p>Specifically, I've somewhere got:</p>

<pre><code>#define MAX_LEN 16
</code></pre>

<p>and I want to use it to prevent buffer overrun:</p>

<pre><code>char val[MAX_LEN+1]; // room for \0
sscanf(buf, "%"MAX_LEN"s", val);
</code></pre>

<p>I'm open to other ways to accomplish the same thing, but standard library only.</p>

I found an answer online.
```
```
#define VERSION_MAJOR 4
#define VERSION_MINOR 47

#define VERSION_STRING "v" #VERSION_MAJOR "." #VERSION_MINOR
```
```
The above does not work but hopefully
    illustrates what I would like to do,
    i.e. make VERSION_STRING end up as
    "v4.47".
To generate the proper numeric form
  use something like
```
```
#define VERSION_MAJOR 4
#define VERSION_MINOR 47

#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)
#define VERSION_STRING "v" STRINGIZE(VERSION_MAJOR) \
"." STRINGIZE(VERSION_MINOR)

#include <stdio.h>
int main() {
    printf ("%s\n", VERSION_STRING);
    return 0;
}
```
```