Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Same exact Code but different results

I am trying to fill a Listbox in a single Dialog based program using names
from a file. I started by using an example program from the MSDN - Modeless.
A simple Dialog based program using a modeless dialog to add strings to a
Listbox in the main dialog. I inserted into the sample program the following
code, which works perfectly:

#include <Fstream>
**********************
BOOL CLeasesDlg::OnInitDialog()
{
..........
........

char* names;
CListBox* pList = (CListBox*) GetDlgItem(IDC_LIST);


infile.open("Leases",ios::in, filebuf::openprot);

while( (infile.getline(names,25,'\n')) != NULL)
{
pList->AddString(names);
}

infile.close();

.............
}

Sunce the sample program was just a stepping stone I created my own Dialog
based program using the AppWizard. I inserted the above code. I now receive
an "unhandled exception" error every time during the "getline" execution. I
have been trying for the last several days to track down the problem but can
not.

Some of what I learned:

First-chance exception in Leases.exe (MSVCIRTD.DLL): 0xC0000005: Access
Violation.

so I wrote code to establish access permissions:

int test = 0;

// Check for existence
if( test = ((_access( "Leases", 0 )) != -1) )
{
// Check for read permission
if(test = ((_access( "Leases", 4 )) != -1) )
{ ........

I stepped thru both with no problem. The file exist and is readable but can
not retreive the first name.

In the disassembly window it stops on this line:

---
strgetl.cpp --------------------------------------------------------------
.......................
..........................
...................
...................
102A75CD 88 08 mov byte ptr [eax],cl


I do not understand how the code can work in the sample program and not work
in the one I created. I looked back at another program I wrote several years
ago and I used the exact same code with no problem. I would think that my
compiler was corrupted but it compiles the modeless sample program.

I am totally baffled .... PLEASE ... PLEASE help!

I would be greatly appreciative








0 Kudos
Message 1 of 2
(4,217 Views)
Hey Randy,
 
This forum is reserved for Measurement Studio questions.  I recommend checking with Microsofts forums because the people there will have more experience doing what you are looking for. 
 
Regards,
jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 2
(4,206 Views)