473,503 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

new , strucure and PROGRAM CRASH

22 New Member
hi
i have a structure xml_data


struct xml_data
{
int prf;
int *pVsipl_buffer;
};




i have declared and allocated memory like this in constructor

data = new xml_data;
data->pVsipl_buffer = new int[LOOP*COL]//LOOP and COL are
//#define(d) constants;
xml_data *data;




now i pass this strucure pointer as an argument to a function (bpg) which resides in another file

bpg(xml_data * ptVsip_obj)
{
for(m=0;m<LOOP;m++)
for(n=0;n<COL;n++)
{
ptVsip_obj->pVsipl_buffer[m*COL+n]; //if i comment this line no
//crashing of program
//else crash
}
}



bpg(data); //crashes


should i have to new the structure and the array in both the files.
(i.e) in called function and calling function.
Dec 18 '07 #1
3 1695
weaknessforcats
9,208 Recognized Expert Moderator Expert
i have declared and allocated memory like this in constructor
What constructor?? I don't see a constructor here.

Maybe you could post the actual struct with the constructor in it plus the constructor itself.
Dec 18 '07 #2
babu198649
22 New Member
What constructor?? I don't see a constructor here.
i have not posted the entire program .

thanks for reply


i have found the error.

while newing the class i have allocated like this

data = new xml_data;
data->pVsipl_buffer = new int(LOOP*COL);


instead of square brace( [LOOP*COL] ) i have used curly brace((LOOP*COL)) .


but it had compiled well but caused runtime error
Dec 19 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
I see. So you created a new int with a value of LOOP*COL rather than an array of int with LOOP*COL elements.

Glad you found it.
Dec 19 '07 #4

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

Similar topics

6
3111
by: Ken | last post by:
When running a program in the debugger, what would cause it to crash without any error messages? I get "The program has exited with code 0 (0x0)". The program is a MDI app with threading for...
6
1587
by: popone | last post by:
Hi All, I've developed a program that seems to crash randomly, from what I can tell it's after some user action. If it just sat there, it wouldn't crash. It's not an exception either, it's the...
5
1591
by: bratiskovci | last post by:
Hello, I am trying to write a few programs using python but don't really know where to start...I am completely CONFUSED. My first program deals with conversion between fahrenheit and celcius...
4
3599
by: eskimo | last post by:
Hello I have a situation, my program has a crash (SIGSEGV) for a reason that I don't know yet. I tried to analyze it using Valgrind but when I invoke the program with Valgrind, the crash no longer...
4
342
by: mike3 | last post by:
Hi. I seem to have made some progress on finding that bug in my program. I deactivated everything in the bignum package that was used except for the returning of BigFloat objects. I even...
4
1904
by: Freddy Coal | last post by:
Hi, I would like know if something libraries or programs exist, and send error with a description if the program don't find the libraries, how can make that?. For example: In the use of...
13
1610
by: Thomas Neubauer | last post by:
Hello, i am learning c# and have created now a simple project that just creates 6 random numbers. My form includes a button and 6 labels for the random numbers. The program seems to work...
2
6395
by: jaddle | last post by:
I program I'm writing crashes when it exits with a segfault. I'm runnning under linux. Using gdb, i see that the crash happens after the last line of main(), which is just a return(EXIT_SUCCESS); If...
11
4035
by: jmnat | last post by:
Hello, Let’s assume the following piece of code : This code works fine, its output is : "Exception : Could not execute f9". Nevertheless, in the catch clause, the pointer c is...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
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
7280
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,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
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
7460
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...
1
5014
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
4672
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
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.