C++ :: Destructor And Inheritance Causing Program To Crash After Running?
Dec 13, 2013
I have a class which dynamically allocates memory for three data arrays, and as such in the destructor I told it to delete those data arrays.
However, when I've created a new class, and inherited the previous class - it will always crash AFTER running the program, unless I don't have the previous destructor present.
I need to do an equivalent of kill -11 <pid>(which is in unix) in windows.
I need to crash a process with SEGV so that it would dump core in windows. Is there any tool by which we can do this . Also is there any sample code through which we can achieve this .
In windows we have taskill which only terminates a process , but is unable to send a signal like SEGV to the process upon which it would terminate and dump core .
Ok, this thing works as far as the getting the image and drawing the rectangle but for the life of me I cannot figure out why it is causing an in the program.cs.
public partial class Crop : Form { public Crop(Image BaseImage) { InitializeComponent(); if ((Bitmap)BaseImage != null) { pbOriginal.Image = BaseImage; }
[Code] ....
BaseImage is pulled in from the main form's picture box.
I am new to C. I've been trying to use C to code some statistical functions originally coded in R. I've encountered an interesting phenomenon. In the function foo1, I declared the array v1v2b using an actual value 1999000. The function runs fine when I call it in R.
Code: void foo1(double *x, double *y, int *nsamp){ int i, j, k, oper=2, l; double* v1v2=malloc(sizeof(double)*((*nsamp)*(*nsamp-1)/2 + 1)); outer_pos(x, y, nsamp, &v1v2[0]); double v1v2b[1999000]; //<-------HERE for(i=1; i<= 1999000]; i++){ v1v2b[i-1]=1; } }
However, in foo2, I first create an integer variable called index, and store the value 1999000 in it. I then use it to initialize the same array. When I tried calling this function in R, it either led to a stack overflow error, or completely crashed R.
Code: void foo2(double *x, double *y, int *nsamp){ int i, j, k, oper=2, l; double* v1v2=malloc(sizeof(double)*((*nsamp)*(*nsamp-1)/2 + 1));
my program crash when it try to assign the return value of the function to the local value. extract function does return correct value, but it just crash when done executing.
since I didn't know how to type epsilon symbol temporarily I am using ^
char prod[20][20],T[20],NT[20],c[10][10],foll[10][10],fir[10][10]; int tt,tnt,tp,a; int follow[20][20],first[20][20]; void first_of(char); int count(int j); void rhs(int j);
i created a windows service that will run another program. but the program i want to run has a gui and i don't want the gui to be visible, i just want the program to run in the background.
But i have to do it without editing the gui program
i tested this code with notepad and it runs notepad in the background without displaying the window but when i try run my program it doesn't work. i don't know why its works for one program and not the other..
I have a problem in my code and after hours of looking I really cannot find out what is the problem.I use scanf to to parse lines of a file, let me copy only the important part:
Code:
/*File read...everything is fine*/ int seq_1, seq_i2; int len; while(fgets(&line[strlen(line)], line_length, file)!= NULL) { }
[code]....
if (num_sc ==4) //the wanted format, do something So I am allocating all variables, and giving to sscanf pointers, so I really don't get where the segmentation fault appears.I checked with the debugger, the first line of the file is read, but at the second it crashes at the line of sscanf! The two lines don't have the format I want in sscanf but therefore I check if this number is 4 and then do other stuff to the data...
I'm working the 4th problem in chapter 14 of the Jumping into C++ book. In the book, he gives an example program for dynamically resizing an array while the program is running. It works fine for integer types but i need to do the same with a string type array. Right now my program is crashing because the string array is not resizing itself. Here's the part of the code im trying to figure out. The part for the int array has been ignored using // since it works fine and I'm trying to figure out whats wrong with the string array.
Code: #include <iostream> #include <string> //Write a program that lets users keep track of the last time they talked to each of their friends. //Users should be able to add new friends (as many as they want!) and store the number of days ago
The assignment is to write a program that statistically computes similarity of C syntax with another program; a same and a different. The one used here is in C language, it's called Battleship.cpp. The program must open a file and read line by line for keywords and then produce statistics. The reason my code is not running is the fopen function is failing and it goes to return -1. I am using MS Visual Studio 2013 and there are no compiler errors after turning off deprecation. I do see, however, this error UMEngx86.dll'. Cannot find or open the PDB file. The file being opened is in my source folder.
The program is not showing my full menu just the 0 Exit and the last line of text. This is the full main source file (not implementation file or header file).
I keep getting the same error messages every time on Visual Studio. I don't know where the error is originating. Basically I'm trying to convert an infix expression (A+B-C) to a postfix expression (AB+C-) using stacks.
I have written a program which uses a pid to check if the process is currently running and return a value based on the system call result.But the program core dumps
Code:
#include <stdio.h> #include <string.h int main( argc, argv ) int argc; char * argv[]; { int p_pid = 99; char buff[1000]; }
[code]....
What is the mistake in this code and is it portable in both unix/linux , is the method secure (grepping for program name )?
I am trying to write a function that extracts chunks of numbers from a stream (ie if i had "ui33ui24ui23hjdwejf" it would extract the chunk 33), and its finished, but it wont compile. errors here: [URL] ...... its only one line in an include file, but im stumped. anyways, this is the most updated version of the code: [URL] .....