Simplest way to write output message to 'output window' in Visual Studio 2010?

后端 未结 6 1680
难免孤独
难免孤独 2020-12-30 01:32

I\'ve tried OutputDebugString function and most of the time I get error like :

error C2664: \'OutputDebugStringA\' : cannot convert parameter 1          


        
6条回答
  •  情书的邮戳
    2020-12-30 01:40

    I found this answer when searching the error message: https://stackoverflow.com/a/29800589

    Basically, you just need put an "L" in front of your output string when using OutputDebugString:

    OutputDebugString(L"test\n");

    It worked great for me.

    Edit:

    For formatting strings with data, I ended up using

    char buffer[100]; sprintf_s(buffer, "check it out: %s\n", "I can inject things"); OutputDebugStringA(buffer);

    By no means am I an expert, I just found something that worked and moved on.

提交回复
热议问题