Write to text file through dll

Hi, guys.

I want to write text to a file, but I want to do this via dll, with a program compiled and called from another application. The program is this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <fstream>
using namespace std;

int main()

{

fstream LogFile;

LogFile.open("Log_file.txt", ios::out);

LogFile << "HELLO" << endl;

LogFile.close();

}


but I compile this code to a dll, and then call it from LabView.

When I run it outside the dll, it works fine; but when I try to do thorugh the dll, the behaviour is really strange: sometimes it works, others, not...

Could you please tell me if I'm missing something?

Thanks in advance.

Regards,
Francisco
This does not appear to be sourced for DLL linking/compilation. You don't have any exposed functions to call from external apps, you don't have a dll main but instead an int main function which is used in console applications.

What IDE are you using? It hopefully has a template project of dll that you can make to see what it looks like? Else search the web for the topic, there's hundreds of articles out there. Depending on your OS and your compiler, you may want to define the externals one way or another.
in my game i do this:

FILE * logfile;

if((logfile=fopen("DEATH.LOG",FOPAA)) != NULL)
{
fprintf(logfile, "[%-10.10s][%-10.10s]:>Log Entry\n",ncdate(today()),nctime(now()));
fclose(logfile);
}
that works from within ARENA.DLL
Topic archived. No new replies allowed.