473,388 Members | 1,385 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Runtime error when using pointers and Files

2
I'm getting a strange crash everytime i try to load a file into a pointer. for example,

fin >> gRecs[i]->ID;
if(fin.fail()) break; //then eof
gRecs = new MeatRecord;
fin >> Tmp;
gRecs->MeatType[i] = eMeatType(Tmp);
fin >> gRecs[i]->MeatCut;
fin >> gRecs[i]->ListPrice;
fin >> gRecs[i]->Amount;

I'm not getting any compile errors and i've declared the pointer correctly.

heres a line from the .txt file

1 1 chops 18.50 50.5

for some strange reason everytime the program gets to loading the file, the whole thing dies. Does anyone have any ideas?
Aug 30 '06 #1
3 1524
Banfa
9,065 Expert Mod 8TB
Is this a typo?

gRecs->MeatType[i] = eMeatType(Tmp);


What is the value of i, is it within range for the array gRecs?
Aug 30 '06 #2
egnaro
2
No, it would not be a typo. i would be a part of a loop, which would start at 0 and would increment after each line is read and put into the pointer.

I've tried to have a look at it and it seems that when it gets to the part of reading the gRecs[i]->ID part is when it dies. I've taken this part out and the program seems to work fine. Any ideas on why this is happening?
Aug 31 '06 #3
Banfa
9,065 Expert Mod 8TB
But shouldn't

gRecs->MeatType[i] = eMeatType(Tmp);

be

gRecs[i]->MeatType = eMeatType(Tmp);

?

What it works if you remove the line that reads ID or if you remove all of the posted code. In the first case check that the data in the file is correct for ID, in the second case like I said check that i is in range for the gRecs array.
Aug 31 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bob Dydd | last post by:
Hi Everybody I have an Access 2000 MDB with the Usual FrontEnd/BackEnd Arrangement. The program depends on being able link to "Inbox" in Ms Outlook 2000. This is easy enough to do from the...
3
by: Bob Dydd | last post by:
Hi Everybody I have an Access 2000 db with a setup for inserting images in records. I am using the image path only with the actual images stored elswhere on the hard disc. This works perfectly...
12
by: ABeck | last post by:
Hello List, I have ar more or less academical question. Can there arise runtime errors in a program, if the include of <string.h> has been forgotten? If all the arguments to the functions of...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
2
by: Joseph Macari | last post by:
Using Acess2003; when writing code, etc. and when attempting to use the help files while in visual basic window, I recently started to get this message- "A runtime error has occurred. Do you wish...
2
by: Aleksandar | last post by:
Hi, I need to convert set of Java classes exported from IBM Modeling environment to C# for implementation. When I invoke JCLA conversion from File->Open->Convert in Visual Studio 2005 it starts...
0
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
9
by: Adrienne Boswell | last post by:
I am getting this error: Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: 'sid' /beta/files/index.asp There is no line number, and there is absolutely nothing on that page...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.