>> ccin.open(data.dat);
I think you mean
ccin.open("data.dat");
Yea i did mean to include the quotes i was tired when i wrote that but i don't think i could make a short version of the program because it is a dialog based program so thers like 7 or 8 different files with all the classes and such and i don't get the error if it is just a normal console program. if you want to look at it i'll post the whole source in a zip file. here is the file where the problem is :
(cust.cpp)
// Cust.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "Cust.h"//this is App's main class declaration file
#include "CustDlg.h"//this is the app's main dialog
#include <fstream.h>
#include <string>
#include <cstring>
using std::string;i need this or else string is undeclared identifier
using std::endl;
using std::getline;// i need this or else getline is an undeclared identifier
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCustApp
BEGIN_MESSAGE_MAP(CCustApp, CWinApp)
//{{AFX_MSG_MAP(CCustApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCustApp construction
//
//
// ********THIS IS WHERE I'm TRYING TO DO THE FILE INPUT********
//////////////////////////////////////////////////////////////////////////////
CCustApp::CCustApp()
{
ifstream ccin;
for (int a=0;a<10;a++) //set default valuse for all custs struct variables (all are CStrings)
{
custs[a].pname="emt";
custs[a].pname="emt";
custs[a].padd="emt";
custs[a].padd2="emt";
custs[a].pcity="emt";
custs[a].pstate="emt";
custs[a].pzip="emt";
custs[a].pcountry="emt";
custs[a].pphone="emt";
custs[a].pemail="emt";
custs[a].bname="emt";
custs[a].badd="emt";
custs[a].badd2="emt";
custs[a].bcity="emt";
custs[a].bstate="emt";
custs[a].bzip="emt";
custs[a].bcountry="emt";
custs[a].bphone="emt";
custs[a].bemail="emt";
custs[a].sname="emt";
custs[a].sadd="emt";
custs[a].sadd2="emt";
custs[a].scity="emt";
custs[a].sstate="emt";
custs[a].szip="emt";
custs[a].scountry="emt";
custs[a].sphone="emt";
}
ccin.open("data.dat");
// THIS IS WHERE I'VE BEEN TRYING A MILLION DIFFERENT THINGS FOR INPUT
string pname; //std::string
getline(ccin,pname);
ccin.close();
}
CCustApp::~CCustApp()
{
WFile();
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCustApp object
/////////////////////////////////////////////////////////////////////////////
// CCustApp initialization
BOOL CCustApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CCustDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
void CCustApp::WFile()
{
ofstream ccout;
// this part is jsut a big for loop with a bunch of ccouts (not important)
}
THESE are the errors i get with the above code:
C:\Documents and Settings\Dave\Desktop\Cust\Cust.cpp(91) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &)' : could not deduce template argument for 'class
std::basic_istream<_E,_Tr> &' from 'class ifstream'
C:\Documents and Settings\Dave\Desktop\Cust\Cust.cpp(91) : error C2780: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &,const _E)' : expects 3 arguments - 2 provided
c:\program files\microsoft visual studio\vc98\include\string(149) : see declaration of 'getline'
Error executing cl.exe.
I tried adding "30" as a third argument, but i just get the same errors only it says expected 2 arguments - 3 provided
NOTE: SORRY I COULDN'T UPLOAD THE FILE IT WAS A LITTLE TOO LARGE SO I'LL JUST MAKE A NEW PROGRAM AND REALLY QUICK AAND POST IT WHEN ITS DONE
the compiler i'm using is whatever one comes with ms visual c++ 6.0
thanks in advance