How do I print floats/integers to the debug window

I did some poking around and I can't seem to find a way to get ints and floats printing to debug window. I'm on Day 9 and wanted to see the stream of values of the sine wave over time. I tried printf but I have no idea where it is outputting, and I'm on the verge of diving into a massive rabbithole of debug error tracking - this should be a really simple solution that someone here must know.

Thanks again!
You need to convert float/int values to string and then use OutputDebugString to print this string. To convert them to string there are multiple options to do that:
1) Write your own function to do that
2) Use some open source code, for example this: https://github.com/weiss/c99-snprintf/blob/master/snprintf.c
3) Depend on C runtime and use sprintf/snprintf function (from <stdio.h> header). Casey shows how to do this in Day 10 at 32:26 mark.

Edited by Mārtiņš Možeiko on
Decidedly less "handmade" but, if you don't mind that, you could use cppformat.

Here is a simple test main:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include "format.cc"
#include <Windows.h>

void DebugPrint(const char *format, fmt::ArgList args)
{
    OutputDebugStringA(fmt::format(format, args).c_str());
}
FMT_VARIADIC(void, DebugPrint, const char *)

int main(int argc, char *argv[])
{
    DebugPrint("x={} y={}\n", 34, 55);
    return 0;
}
Awesome guys, I'll check these out, thank you!