473,513 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

First-chance exception in data_generation.exe: 0xC0000005: Access Violation.

8 New Member
hi all
can anyone please help me with this error.code was working properly earlier giving appropritae results before addign the functions :
assign_ordersize();
user_data.printodsize();

this is my code :
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
//using namespace std;

class data
{
int Machno,Lotn;
int *lots,*wl;
int **ordersinM;
//int *wl;
int *JM;
int totalotsz;
int totalodsz;

public:
void initvalues()
{
int i;
cout<<"Enter the number of lots being processed";
cin>>Lotn;
cout<<"Enter the number of EDS lines in the system";
cin>>Machno;
JM = (int *) malloc(Machno);

for(i=0;i<Machno;i++) {
cout<<"Order for line "<<i;
cin>>JM[i]; }
}
int getnoflots()
{
return Lotn;
}
void ass_lotsize()
{
int i,temp;
totalotsz=0;
wl = (int*) malloc(Lotn);
srand(time(NULL));

for(i=0;i<Lotn;i++) {
//do {
temp = rand()%10 * 5;
//}while(temp!=0);

wl[i] = temp;
totalotsz=+temp;}
cout<<"totallot size : "<<totalotsz;
}
int maxJM()
{
int max = 0;
int i;

for(i=0;i<Machno;i++)
if(JM[i] > max)
max = JM[i];
return max;
}



int * accesslotsize(){
return wl;
}

void assign_ordersize()
{
int i,j;
int temp;
totalodsz=0;
ordersinM = (int **)malloc(Machno*maxJM()*sizeof(int));
for(i=0;i<Machno;i++)
{
for(j=0;j<maxJM();j++)
{
//do {
temp = rand()%100;
//}while(temp!=0); */

ordersinM[i][j]=temp;
totalodsz =+ temp;
}
}
cout<<"total order for all the lines "<<totalodsz;
}

void printodsize()
{
int i,j;

cout<<"Order size generated are :"<<endl;
for(i=0;i<Machno;i++)
{
for(j=0;j<maxJM();j++)
{
cout<<"line "<<i<<" order "<<j<<" : "<<ordersinM[i][j];
cout<<endl;
}
}
}


};


void main()
{
class data user_data;
int *uwl;
int i, temp,limit;

user_data.initvalues();
cout<<"these are the lot sizes"<<endl;
user_data.ass_lotsize();
uwl = user_data.accesslotsize();
limit = user_data.getnoflots();

for(i=0;i<limit;i++)
cout<<uwl[i]<<endl;

user_data.assign_ordersize();
cout<<"i m not reading this";
user_data.printodsize();

}
May 1 '07 #1
1 2359
gpraghuram
1,275 Recognized Expert Top Contributor
Hi,
You are not allocating memory for the second dimension array in the code...
[code]
ordersinM = (int **)malloc(Machno*maxJM()*sizeof(int));
for(i=0;i<Machno;i++)
{
for(j=0;j<maxJM();j++)
{
//do {
temp = rand()%100;
//}while(temp!=0); */

//ordersinM[i][j]=temp; // Issue is here
//Allocate memory for ordersinM[i][j] first and store the value....
totalodsz =+ temp;
}
}
[code]

Thanks
Raghuram
May 1 '07 #2

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

Similar topics

5
5150
by: Mel | last post by:
i want to have a block, like some articles i see, with the first char (very Fancy and huge) and have the rest of the block kind of wrap around this char (to the right of). something like below...
12
6006
by: Alan J. Flavell | last post by:
OK, today's email brought a comment from a reader, pointing out something that I'd long since noticed myself but hadn't done anything about it. On my pages, I've got a first-letter style on...
6
16599
by: Veerle | last post by:
Hi, Somewhere in my html page, I have the following code: <div id="main-body"> <h2>Header text</h2> <p>Some other text ...</p> ..... <h2>Another header text</h2> <p>Some more other text...
3
23190
by: news.individual.net | last post by:
Hi! Can I capitalize the first letter of the first paragraph without using a special class for that <p> ? I tried it with this: body > p:first-child:first-letter { font-size: 270%;
3
2476
by: Chris Tanger | last post by:
I am creating a class that has a method "Write" that I wish to make threadsafe. The method must block calling threads until the task performed in write is complete. Only 1 thread at a time can...
43
2765
by: Roger L. Cauvin | last post by:
Say I have some string that begins with an arbitrary sequence of characters and then alternates repeating the letters 'a' and 'b' any number of times, e.g. "xyz123aaabbaabbbbababbbbaaabb" I'm...
6
4205
by: =?Utf-8?B?UGF1bA==?= | last post by:
HI I have a stored procedure that returns data with a date field in the form of a DateTime type. I need to place data in variables based on days of the week starting with the first thursday of the...
4
2163
by: Milan Krejci | last post by:
int first=15,latest=15; QString typ=NULL; std::map<int,std::string>::iterator i; for(i = SeznamPracovniDoby.begin(); i != SeznamPracovniDoby.end(); i++) { if (typ==NULL) typ=i->second.c_str(); if...
3
419
by: cs | last post by:
Hi, I'm new to C and would appreciate any feedback on the following program, asplit, which splits a file into 2 new files, putting a certain number of lines in the first file, and all the rest...
3
5028
by: dmalhotr2001 | last post by:
Hi, For string extraction function in vb, if I feed in a paragraph, how do I extract the first sentence of that paragraph. Thanks :D
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7114
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...
0
7541
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5693
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3230
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.