I'm running some C++ code and have been noticing some weird behavior. For instance, my std::cout prints are only printing out a part of the string that I tell it to print.
Here is a small section of my code (this code gets called repeatedly):
std::ofstream file;
file.open("cout_img.txt", std::ofstream::out | std::ofstream::app);
std::streambuf* sbuf = std::cout.rdbuf();
std::cout.rdbuf(file.rdbuf());
std::cout << "Reached Display Function NOW";
std::string frame_file_name = std::string("demo") + std::to_string(saveImgNum) + std::string(".bmp");
std::cout << frame_file_name + '\n';
For instance, in this section I'm only printing out "splay Function NOW" each time instead of the full string "Reached Display Function NOW". I'm also not even printing out the frame_file_name variable.
Could this mean I'm experiencing a memory leak somewhere? If so, does the section of code I posted look suspicious at all? Is it because I have to deallocate variables such as the std::string variable?
What else can I look for? I'm using CPython API (Python embedded in C++) if that makes a difference.
Thanks so much!