hello, I have been working on a code that would create a .dll file for dbpro (which would add commands to dbpro). I am currently using vs 6.0 c++ and I am having a problem with my code. I am trying to write text to a file using <fstream> but when I use ifstream file; (code bellow) it says that file and ifstream are undefined, can anyone help me? thanks in advance!
errors:
Compiling...
WRITEFILE.cpp
C:\Users\parker\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio\MyProjects\WRITEFILE\WRITEFILE.cpp(28) : error C2065: 'ifstream' : undeclared identifier
C:\Users\parker\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio\MyProjects\WRITEFILE\WRITEFILE.cpp(28) : error C2146: syntax error : missing ';' before identifier 'file'
C:\Users\parker\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio\MyProjects\WRITEFILE\WRITEFILE.cpp(28) : error C2065: 'file' : undeclared identifier
C:\Users\parker\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio\MyProjects\WRITEFILE\WRITEFILE.cpp(29) : error C2228: left of '.open' must have class/struct/union type
C:\Users\parker\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio\MyProjects\WRITEFILE\WRITEFILE.cpp(32) : error C2228: left of '.is_open' must have class/struct/union type
C:\Users\parker\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio\MyProjects\WRITEFILE\WRITEFILE.cpp(34) : error C2297: '<<' : illegal, right operand has type 'char [6]'
C:\Users\parker\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio\MyProjects\WRITEFILE\WRITEFILE.cpp(39) : error C2228: left of '.close' must have class/struct/union type
Error executing cl.exe.
WRITEFILE.dll - 7 error(s), 0 warning(s)
code:
// WRITEFILE.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return true;
}
#define COMMAND _declspec ( dllexport )
COMMAND void PrintText( LPSTR pString )
{
ifstream file;
file.open("hello.txt");
if (pString)
{
if (file.is_open())
{
file << "hello";
}
}
file.close();
}
COMMAND int GetValue ( void )
{
return 42;
}
sov the game creator!