Storing an integer into a char* in C++
Question
I'm writing some code that returns an integer, which then needs to be outputted using printw from the ncurses library. However, since printw only takes char*, I can't figure out how to output it.
Essentially, is there a way to store a integer into a char array, or output an integer using printw?
Solution
printw()
accepts const char *
as a format specifier. What you want is
printw("%d",yournumber);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow