Graphviz 13.0.0~dev.20250608.0154
|
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | itos_ |
return type of itos_ More... | |
Macros | |
#define | ITOS(i) (itos_(i).str) |
Functions | |
static struct itos_ | itos_ (long long i) |
convert a signed number to a string
The string returned by this macro has a lifetime that (under ≥C11 semantics) only lasts until the end of the containing full expression. Thus intended usage is something like:
void foo(char *); foo(ITOS(42));
In particular, it is incorrect to store the result of this macro anywhere:
char *p = ITOS(42); // ← WRONG // p is now a dangling pointer, pointing to deallocated stack memory
You can think of ITOS
as a C equivalent of the C++ std::to_string(i).c_str()
.
i | Number to convert |