GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-May-2004, 07:11
Nelly Nelly is offline
New Member
 
Join Date: Apr 2004
Posts: 15
Nelly is on a distinguished road

Application error


Hello,

Can anyone help me to understand the following error I get while running my program:

" This instruction at "0x10213035" referenced memory at "0x00000065". The memory could not be read.
Click on OK to terminate the program"

and

" This instruction at "0x102125fe" referenced memory at "0x00000092". The memory could not be written.
Click on OK to terminate the program".
  #2  
Old 03-May-2004, 07:18
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
your program is trying to access the region of memory that it shouldnt. system is denying it access and terminating it. either your accessing it thru your array or a pointer. post your code if you need help in figuring it out
  #3  
Old 03-May-2004, 08:17
Nelly Nelly is offline
New Member
 
Join Date: Apr 2004
Posts: 15
Nelly is on a distinguished road
representing different feature points on a face, which is extracted from a video frame.
CPP / C++ / C Code:
struct Face  
  {
	int Mouth;	
	int Eye;							int nose				
             int FrameNo;			
   };


When I press the Apply button on my FormView, to save my Structure to my vector called 'Feat'.
CPP / C++ / C Code:
void CFeature::OnApply() 
{
	// TODO: Add your control notification handler code here
	CMFFADoc* pDoc = GetDocument();
	UpdateData(TRUE);

	 pDoc->m_pnt.x = m_X ;
	 pDoc->m_pnt.y = m_Y ;
	 pDoc->m_CurrentFrame = FaceFeat.FrameNo;



	 // 3 - Tell the document something happened
	pDoc->SetModifiedFlag( TRUE );

	// 4 - Synchronize all other views
	pDoc->UpdateAllViews( this );

	//Save Face buffer to vector
	saveFeatures( Feat);
	
}

This is save function the save structure to the vector:
Please note that I need to save(push) several Face structure in the vector.
that is each time I press the Apply button, I need to push a different set of Face to the vector:
CPP / C++ / C Code:
void CFeature::saveFeatures (std::vector < Face > & Feat)
{
	
	Feat.push_back(FaceFeat);
	return;
}

Then I have another button on my FormView to save the Vector to a file:
CPP / C++ / C Code:
void CFeature::OnSaveft() 
{
	CMFFADoc* pDoc = GetDocument();

	 
	//  Synchronize all other views
	pDoc->UpdateAllViews( this );
            WriteFaceVector(ftname ,  Feat);
}

This function write the vector to the file.
I'm taking info (Structure) from a video file(.vid) and save them in a new file with the same name as the video file but with (.fea) ext:
CPP / C++ / C Code:
bool CFeature::WriteFaceVector(  char * ftname , const vector<Face> & v)
{
	m_FtFileName =  VC.m_VidFileName;

	//Need to convert file name from CString to Char*
	ftname = m_FtFileName.GetBuffer(m_FtFileName.GetLength());
	
	char* pos;

	pos = strrchr(ftname,'.');//Find the ext
	*(pos+1) = 0;
	strcat(ftname,"fea"); //Create new ext
	ofstream m_FeatureFile(ftname,ios::binary);
    if (!m_FeatureFile) return false;

	std::vector<Face>::size_type size(v.size());
    m_FeatureFile.write(reinterpret_cast<const char*>(&size), sizeof (std::vector<Face>::size_type));     

    for(std::vector<Face>::size_type i =0; i < size; ++i)
    {
      if(0 != size)
    m_FeatureFile.write(reinterpret_cast<const char*>(&v[i]), size * sizeof   (Face));
    }
  return true;
}

hope the explanation is clear enough.
Last edited by Garth Farley : 03-May-2004 at 11:02. Reason: Please enclose code with [C++] and [/C++] for syntax highlighting. GF
  #4  
Old 03-May-2004, 08:35
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
Quote:
//Need to convert file name from CString to Char*
ftname = m_FtFileName.GetBuffer(m_FtFileName.GetLength());

what data type is m_FtFileName? and what exactly does GetBuffer return? Does it return a pointer to the filename?

if possible, can u post the code to GetBuffer function?
  #5  
Old 03-May-2004, 12:36
Nelly Nelly is offline
New Member
 
Join Date: Apr 2004
Posts: 15
Nelly is on a distinguished road
the m_FtFileName is a string, the variable for my new file.
First, I've assigned it the same value as the video file VC.m_VidFileName, which is also a string.
Then i've used:
CPP / C++ / C Code:
  m_FtFileName.GetBuffer(m_FtFileName.GetLength());
to get the Filename, so that I can find the position of the ext ('.') by doing:

char* pos;

  pos = strrchr(ftname,'.');//Find the ext
  *(pos+1) = 0;
  strcat(ftname,"fea"); //Create new ext
Last edited by dsmith : 04-May-2004 at 08:23. Reason: Please use [c] & [/c] for syntax highlighting
  #6  
Old 03-May-2004, 13:44
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
Quote:
Originally Posted by Nelly
the m_FtFileName is a string, the variable for my new file.
First, I've assigned it the same value as the video file VC.m_VidFileName, which is also a string.
Then i've used:
m_FtFileName.GetBuffer(m_FtFileName.GetLength());
to get the Filename, so that I can find the position of the ext ('.') by doing:

char* pos;

pos = strrchr(ftname,'.');//Find the ext
*(pos+1) = 0;
strcat(ftname,"fea"); //Create new ext

what class type is m_FtFileName object of? is it the string class included in <string> or is it some other class and library?
  #7  
Old 04-May-2004, 02:01
Nelly Nelly is offline
New Member
 
Join Date: Apr 2004
Posts: 15
Nelly is on a distinguished road
#include <string>

CString m_m_FtFileName;
  #8  
Old 04-May-2004, 09:52
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
i tried using #include<string> and then declaring a CString type, but my compiler can't find that type in the string header. If possible, upload all your source files, so i can compile them on my own compiler and get a clear picture.
  #9  
Old 04-May-2004, 20:48
Max Payne's Avatar
Max Payne Max Payne is offline
Regular Member
 
Join Date: Apr 2004
Location: 3° 08 North 101° 42 East
Posts: 332
Max Payne is a jewel in the roughMax Payne is a jewel in the roughMax Payne is a jewel in the rough
I believe that CString is only for VC++ user, and the header is not string.h.

Nelly,
I don't find any clues about your code, I mean where the problem might come from, so if your project is not big, you may post it for others to see. I may take a look at it hoping I can solve your problem.
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds
 
 

Recent GIDBlogStupid Management Policies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Operator Overloading: << aaroncohn C++ Forum 36 07-Dec-2004 20:22
Visual C++ 6 Compiler error vip3r C++ Forum 2 13-Apr-2004 15:34
compilation error cameron C++ Forum 18 20-Feb-2004 01:41
error during program rjd72285 C++ Forum 0 11-Nov-2003 19:49
[script] E-mail webmaster error page BobbyDouglas PHP Code Library 0 19-Aug-2003 21:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:04.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.