Problème avec ifstream et les headers
Bonjour tout le monde,
Je voudrais savoir pourquoi j'ai des erreurs vraiment bizarres quand je fais une application Window console application qui support MFC. Je vous montre le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
// PCITest.cpp : Defines the entry point for the console application.
//
#include <fstream.h>
#include "stdafx.h"
#include "PCITest.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
ifstream *f;
char deviceName[60];
do
{
strcpy(deviceName,"\\\\.\\");
char name[15];
cout << "Enter device name: ";
cin.getline(name,sizeof(name));
strcat(deviceName,name);
f = new ifstream(deviceName);
if (f==NULL || f->is_open()==false) cout << "\nUnable to open device \"" << deviceName << "\"" << endl;
}
while (f==NULL || f->is_open()==false);
return nRetCode;
} |
Quand je compile ça me donne des erreurs du styles:
- error C2514: 'std::basic_ifstream<char,struct std::char_traits<char> >' : class has no constructors
error C2027: use of undefined type 'basic_ifstream<char,struct
error C2227: left of '->is_open' must point to class/struct/union
error C2027: use of undefined type 'basic_ifstream<char,struct error C2227: left of '->is_open' must point to class/struct/union