dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Weird Problem

  1. #1
    Join Date
    Jul 2007
    Posts
    116

    Weird Problem

    Hi all,

    Code:
    #include "stdafx.h"
    #include "Asimulator.h"
    #include "inputBoxAP.h"
    #include <cstring>
    #include <fstream>
    
    // inputBoxAP dialog
    
    IMPLEMENT_DYNAMIC(inputBoxAP, CDialog)
    
    inputBoxAP::inputBoxAP(CWnd* pParent /*=NULL*/)
    	: CDialog(inputBoxAP::IDD, pParent)
    	, amtAP(0)
    {
    	
    }
    
    inputBoxAP::~inputBoxAP()
    {
    }
    
    void inputBoxAP::DoDataExchange(CDataExchange* pDX)
    {
    	CDialog::DoDataExchange(pDX);
    	DDX_Text(pDX, IDC_EDIT1, amtAP);
    	DDV_MinMaxInt(pDX, amtAP, 3, 5);
    }
    
    
    BEGIN_MESSAGE_MAP(inputBoxAP, CDialog)
    	ON_EN_CHANGE(IDC_EDIT1, &inputBoxAP::OnEnChangeEdit1)
    	ON_EN_UPDATE(IDC_EDIT1, &inputBoxAP::OnEnUpdateEdit1)
    	ON_BN_CLICKED(IDOK, &inputBoxAP::OnBnClickedOk)
    END_MESSAGE_MAP()
    
    
    // inputBoxAP message handlers -- The most imprt handler is OnBnClickedOK(), the rest don't care
    
    void inputBoxAP::OnEnChangeEdit1()
    {
    	// TODO:  If this is a RICHEDIT control, the control will not
    	// send this notification unless you override the CDialog::OnInitDialog()
    	// function and call CRichEditCtrl().SetEventMask()
    	// with the ENM_CHANGE flag ORed into the mask.
    
    	// TODO:  Add your control notification handler code here
    	
    }
    
    void inputBoxAP::OnEnUpdateEdit1()
    {
    	// TODO:  If this is a RICHEDIT control, the control will not
    	// send this notification unless you override the CDialog::OnInitDialog()
    	// function to send the EM_SETEVENTMASK message to the control
    	// with the ENM_UPDATE flag ORed into the lParam mask.
    
    	// TODO:  Add your control notification handler code here
    }
    
    void inputBoxAP::OnBnClickedOk()
    {
    	// TODO: Add your control notification handler code here
    	OnOK();
            
            ofstream inputdata; < -- ERROR HERE
    
    	// To test if the operation is functioning correctly
    	CString temp;	
    	temp.Format(_T("%d"),amtAP);
    	AfxMessageBox(temp);
    }
    Notice that at the last function, i include ofstream inputdata, but there is always an error produced:

    ofstream undeclare identifier.

    What is wrong here?

  2. #2
    Join Date
    Jun 2004
    Location
    India
    Posts
    432

    Re: Weird Problem

    ofstream is inside of namespace std. Use it like this

    Code:
    std::ofstream f;
    Say no to supplying ready made code for homework/work assignments!!

    Please rate this post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)