C++ :: Program Crashing When Initialized

Oct 13, 2014

I just finished coding a program that is based on polymorphism and inheritance but when I ran the program it crashed? I do not know what is the cause of the program crashing.

#include<iostream>
#include<string>
using namespace std;
class Shape{
float density;

[code].....

View 9 Replies


ADVERTISEMENT

C++ ::  program Is Crashing When Trying To Call

Sep 5, 2013

My program is crashing when I'm trying to call b = a. What has me confused is that when I call c = d = b, it all works fine.

I actually think I see it now that I posted this. In operator= I'm changing the size, but I'm not changing the size of the array that it's pointing to correct? I'm keeping it as 'p = new T[size]' rather than changing it to 'p = new T[x.size]' correct?

#include <iostream>
#include "Array.h
int main() {
std::cout << "creating Array< int > object a ...

[code]....

View 13 Replies View Related

C :: Program Crashing When Deleting A Record

May 5, 2013

Code:

#include<stdio.h>
//bookData structure
struct bookData {
int recordNum;
char description[ 15 ];
int booksBought;
double bookCost;

[code]...

I am able to add records and show records, no problem. But when I go to delete a record, it crashes immediately after inputting the record number I want to delete. I don't see why. I've set it up exactly like the example in my book, having of course changed the variable names for my program. Does it have something to do with the pointer?

View 3 Replies View Related

C :: Program Seems To Be Crashing At Random Numbers

Mar 3, 2014

When I go to run the Fibonacci function ( fib ), it begins to return incorrect calculations towards the higher numbers, but then seems to correct itself for a little bit, but then does it again and ultimately crashes. And the program seems to be crashing at random numbers. Sometimes the it will make it up to F(55), other times it will only get to F(20).

Also, when I go to run the program on a Linux server, it segfaults, but it doesn't when I just run it on my IDE. the function adds two arrays with individual digits together. It does this to allow the program to add numbers that would exceed the boundaries of INT_MAX.

Here is the header file "Fibonacci.h":

Code:

#ifndef __FIBONACCI_H
#define __FIBONACCI_H
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
}

[code]....

View 12 Replies View Related

C :: Program Keeps On Crashing When It Finishes Case 1?

Oct 18, 2013

The program keeps on crashing when it finishes case 1

View 5 Replies View Related

C++ :: Program Crashing On Exit While Multithreading

May 11, 2014

I was writing a program and it started crashing on exit (segment fault), after the 'return 0' in main(). I figure it's an std destructor.

I started with the program I was writing and just stripped out as much as I could, while making sure the crash persisted. If I remove any of the remaining code the crash disappears, even the seemly unrelated or scoped code.

#include <iostream>
#include <fstream>
#include <condition_variable>
#include <mutex>
#include <thread>

/* Call stack results:

[Code] ....

View 2 Replies View Related

C :: Program With Fscanf Keeps Crashing - Using Eclipse Kepler

Oct 13, 2013

So this program I have to make keeps spitting out an error report when I try and run it. I am using eclipse C kepler.

The file it is supposed to read has the following text;

R1 N001 N003 20
R2 N002 N001 5
R3 N001 0 10
R4 N002 N003 10
R5 N003 N000 5
I1 0 N002 10

View 2 Replies View Related

C/C++ :: Program Crashing On A Function Call In Main?

May 5, 2014

i have this program I am working on and it seems to crash after the function call getdata()

here is the code

#include<iostream>
#include<string>
#include<cstdlib>

[Code].....

View 1 Replies View Related

C++ :: Program Crashing When Reading Text From Files

Feb 5, 2014

I'm writing a code obfuscator in C. Debugger shows no errors in the code, but the program crashes after compiling -- I'm guessing it has something to do with while loops or reading data from files.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// list off all replaced elements
typedef struct ReplaceList {
char *from;// from string
char *to;// to string (random)

[Code] ....

View 3 Replies View Related

C :: Variable F Is Being Used Without Being Initialized

May 6, 2013

I have declared and initialized where needed but keep getting a Debug Error: Variable F is being used without being initialized.

Code:

#include "stdafx.h"
#include<stdio.h>
void Signboard (void)
{
/* This function prints the Signboard onto the output page */
int n;
}

[code]....

View 4 Replies View Related

C++ :: Variable Mean Is Being Used Without Being Initialized

Jan 27, 2013

#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;
int studentdetails_mean();
double standard_deviation();

[Code] .....

its showing Run-Time Check Failure #3 - The variable 'mean' is being used without being initialized.

View 11 Replies View Related

C++ :: Variable P Being Used Without Being Initialized

Jan 16, 2014

There is error that said run time check failure 3 the variable p is being used without being initialized

typedef struct portion{
char type[8]; float pctg;
struct portion *next;
}Portion;

typedef struct student{
char ID[9]; float cmark;
Portion *head;

[Code] .....

View 1 Replies View Related

C :: Compiler Keeps Freezing / Crashing

Feb 11, 2014

I wrote this code as an assignment

Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
main(){

int story, age=0;
int ranColor, ranCar, ranItem;

[Code] ....

And my compiler keeps freezing/crashing. using Dec C++

View 4 Replies View Related

C :: Pointer Cannot Be Initialized With A Constant

May 20, 2014

Why pointer cannot be initialized with a constant like.

Code: int *p = 3000;

View 6 Replies View Related

C++ :: Variable (Width) Is Being Used Without Initialized

Mar 14, 2013

It said my width1 is being used wihtout being initialized.. what does it mean?

#include<iostream>
using namespace std;

double Area(double height, double width);
double Perimeter(double height, double width, double height1, double width1);

[Code] .....

View 2 Replies View Related

C++ :: Console Applications Keep Crashing

Jan 11, 2013

Any time I run my program after I make a selection from the menu the output is printed on the console screen then immediately a windows screen comes up saying project.exe has stopped working.

Below is my code, and I suspect the error has something to either

A) due with how I'm calling the method or
B) how I have the method coded.

Main
#include <iostream>
#include <fstream>
#include <string>
#include "telephone.h"
#include "tbook.h"

[Code] .....

View 4 Replies View Related

C/C++ :: Red Black Tree - App Keeps Crashing

Dec 8, 2014

Red Black Trees. [URL] .....

My app keeps crashing after about the 49th insert.

I tried debugging and it keeps pointing to this area in the Fixup:

if (z->parent == z->parent->parent->left) {
y = z->parent->parent->right;

View 13 Replies View Related

C++ :: Tail Stiva Crashing To Print?

Nov 17, 2014

i am trying to break a string and store it to a stiva (tail) i need my program to take one function like this

(a+10)* ((b+c)/(d-5)) + (9*2)

and return if it is editorial correct for example for the apper function has to return true but for this function

((a+10)*((b+c)/(d-5)) + (9*2)

has to return false.it crashes in the last part of my list i will put a comment

Code: #include<iostream>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
using namespace std;
struct node{
char info;
node *back;
};

[code]....

View 2 Replies View Related

C++ :: Function Argument - Variable Is Being Used Without Initialized

Jan 27, 2015

I get an error when i try to compile this code. I tried to allocate memory in main function and that works. But why it doesn't work in function? I think that there is something wrong with function argument, but not sure.

Code:

#include <iostream>
#include <fstream>
using namespace std;
struct Word

[Code].....

View 2 Replies View Related

C :: Qsort With Array Initialized Using Malloc?

Mar 2, 2013

I want to be honest, this is FOR homework, but is NOT homework. I have created this example to work from in order to understand qsort further because the next assignment requires it's use.

Our teacher gave us this small piece of example code and I am trying to expand on it to serve my purpose.
[C] Sorting - Pastebin.com

The code gives me no errors, but does not sort the array. Need to clarify the use of qsort in this instance.

I am imagining that the reason it's not sorting properly ( or at all ) is because of my comparison function. That is really just an assumption. Or perhaps I just don't understand the pointer array i'm using.

View 3 Replies View Related

C++ :: Elements Of Array Will Be Default Initialized

Sep 1, 2014

I have a `char*` data-member in a class.

I get the following compiler error, the error refers to the char* data member:

error C4351: new behavior: elements of array will be default initialized.

View 1 Replies View Related

C++ :: Copy Constructor With Array Crashing

Oct 7, 2014

I know everything works except my copy constructor! There are no errors. The program crashes when it goes to access the copy constructor. why the copy constructor isn't working?

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstring> // access to C str functions
#include "String.h" // access String class
using namespace std;
String::String( int size )// default constructor

[code].....

View 2 Replies View Related

C++ :: Console App Crashing After Calling Function

Jul 18, 2014

Im new to debugging but it says the problem is on line 97 which is the verb menu function being called in the first switch statement case 0:

verb menu is one of the sub menus i want ,and it loads but then it crashes ...

#include <iostream>
#include <string>
#include "spanishverbs.h"
#include <windows.h>
#include <cmath>
#include <cstdlib>
using namespace std;
void nounmenu();

[Code] ....

View 3 Replies View Related

C/C++ :: Elements Of Array Will Be Default Initialized?

Sep 1, 2014

I have a `char*` data-member in a class.

I get the following compiler error, the error refers to the char* data member:

error C4351: new behavior: elements of array will be default initialized.

View 1 Replies View Related

C++ :: How Many Times Is A Const Variable Initialized

Jan 12, 2012

I hope I got all the jargon correct. I have something like this:

Code:

const Fl_Color my_fl_dark_gray=fl_color_cube(64*(FL_NUM_RED-1)/255, 64*(FL_NUM_GREEN-1)/255, 64*(FL_NUM_BLUE-1)/255);

in a header file and the header file is included in several C files.

Questions:

At run time,

Is there just one copy of the const variable my_fl_dark_gray or are there multiple copies for the multiple C files?If a function uses the const variable, does the initialization statement "my_fl_dark_gray=fl_color_cube(...);" run every time the function is called or does it just run once and then when the function is called it just uses the value stored in memory?

View 9 Replies View Related

C++ :: How To Copy From A Dynamic Array Initialized In A Class

Apr 3, 2013

How do I copy from a dynamic array initialized in a class but with a different memory address. For example if my array is a dynamic array initialized in a class...

Code:
const int CAPACITY=5;
class Array{
public:
Array();//constructor

[Code] .....

How would i copy this array to a another array but have a different memory address so when i deallocate array a my copy array also isn't deallocated.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved