printf prints twice for some reason, cout seems okay though [closed]
I've written a library and I'm trying to statically link it to my main program. My main program is written in C++, but the library is in C. I noticed some of the debugging printf statemen开发者_如何学Gots in my library running twice where they shouldn't for some reason, so I started commenting out code. I'm now left with this (comments excluded):
#include <iostream>
extern "C"
{
include "audio.h"
}
int main(int argc, char** argv)
{
std::cout << "Hello" << std::endl;
audio_test();
std::cout << "World" << std::endl;
return 0;
}
The function audio test is not interesting at all. This is from a C file that I'm trying to use in my C++ project.
void audio_test()
{
printf("TEST\n");
}
The output from my program is this:
Hello
TEST
TEST
World
I have no idea at this point why this is happening.
Call std::ios_base::sync_with_stdio(true)
and it will probably work better.
精彩评论