Code: Select all
char msg[] = "This is some text!\0";
The \0 is not really necessary...the compiler will automatically put it onto the end of string literals, but I guess it doesn't really hurt.
The fact that streams are not a part of C
shouldn't make a difference (although I won't say it doesn't). Do you have access to a debugger, such as Visual C++? It would be helpful to be able to look at the call stack when the crash occurs, if that feature is available.
Also, what is "LogFile"...is it a constant? Try changing it to a string literal, just as a test:
Code: Select all
fstream fs("testlogfile", ios::in | ios::out | ios::binary);
Also, out of curiosity, is there some reason you're writing the logfile in binary mode? If you're just writing text, you probably don't want binary mode, although that shouldn't make the program crash.
If you know for certain that the problem is occurring at the call to fs.write, then the problem is probably either with the fs object or your pointer. Given that your function with no pointer still crashed, there's a good chance it's a problem with the fs object, but again there are no guarantees.
If it's a problem with the multi-threading library, I don't really have enough experience with it to diagnose the problem.