-
May 17th, 2022, 09:47 AM
#1
What's wrong with my std::ostringstream usage
Tried to my update my window title with some performance metrics for my vulkan renderer with std:stringstream. When i run it tells there's access violattion leading to xtring file funtion size_t length(_In_z_ const _Elem* const _First) where the the _First parameter is null as shown on picture below. Here's the code i wrote
Code:
void ApplicationBaseVk::UpdatePerformanceMatrics()
{
std::ostringstream osstream;
osstream << mWindowTitle << " Frametime : " << mDeltaTime << " FPS : " << 1.0f / mDeltaTime;
glfwSetWindowTitle(mWindow, osstream.str().c_str());
}
Or maybe i've done in wrong way.I'm running latest msvc 2022.Sorry for my bad english.Thank you
-
May 17th, 2022, 10:18 AM
#2
Update: I tried on simple console app and it works fine.This confusing me.
Code:
#include <iostream>
#include <sstream>
int main()
{
int i = 0;
std::ostringstream ss;
ss << "Hello" << i << "\n";
std::cout << ss.str().c_str();
}
-
May 17th, 2022, 10:48 AM
#3
Re: What's wrong with my std::ostringstream usage
Update : It turns out I forgot to do
Code:
mWindowTitle = appName;
in my app initialization function.Foolish me. Sorry for the trouble. Have a nice day folks.
-
May 17th, 2022, 11:29 AM
#4
Re: What's wrong with my std::ostringstream usage
We've all made stupid mistakes at least once, twice...
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|