#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?
I want to delete selected records from struct array using cstring reading from files. Here I read my records to stud struct then assign non-deleted to stu struct but its not deleting as desired...strcmp is giving 25
while(cont=='Y'){ cout<<"Enter student ID to delete: "; cin.ignore(); cin.getline(id, 15,
[Code] ....
I did some debugging effort and I found here is the problem..the stud[0].ID and id is not same but why? I am giving in same id and both char array lenght is 15
while(cont=='Y'){ cout<<"Enter student ID to delete: "; cin.ignore(); cin.getline(id, 15); cout<<strlen(stud[0].ID)<<" "<<strlen(id)<<endl;///---> lenght 1 is 10 ///---->lenght 2 is 8 cout<<strncmp(id,stud[0].ID, 10 )<<endl;
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 ...
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;
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; }
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.
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)
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.
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
This program I'm working on accepts an array size from the user, prompts the user to store that many integers, sorts them from smallest to largest, and then searches for duplicates with a simple for loop. The ultimate goal of the assignment was to display duplicates in an array, and the rest of the functions are just how I decided to reach that goal.
Anyway, my program crashes if I choose an array size larger than 7. It sorts and displays duplicates perfectly with 7 or fewer arguments.
The exact moment it crashes is after I enter the final value it prompts me for, so it appears my inputsize() function and my inputarray() function are working, and the error may be in the arrsort() function. Code is below:
Code: #include <stdio.h> int funcinputsize(int); void funcinputarray(int [], int size); void funcarrsort(int [], int size); void funcdupe(int [], int size);
The first problem i'm having is in the following code.
Code: #include<stdio.h> #include<stdlib.h> #include<time.h> // program ask for max value and always returns random numbers < max
[Code].....
The ultimate goal of these two programs is to merge them and make one program that takes a max value from the user and fills up an array of (10^6) elements with values ranging from (0 to maxValue).
I've been making a multilayer game for a while and have a config that the game loads for the IP and stuff. I just recently put all the loading stuff into a function just so its easier to go through the code, but now the game isn't really working. It works fine on my computer connecting to the server myself, but when someone else tries to do it it seems like the game is working like it says the IP and everything from the config. When it tries to connect it either doesn't work or crashes just saying the program stopped working. Here is the code... I don't know if this is what is causing it to not work or something else.
other posts talk about the fopen function and don't really give any solutions to this the var that has the file path is a char* and has been converted from a system::string^ it is completely valid when I paste it in windows bar.
it crashes right at the pile.open() function call when I put breakpoints in it says , debug assertion failed and shows me the fclose.c file location and Expression: (stream != NULL)
I developed the following heap sort algorithm code, and for some reason anytime it goes above 4100 entries, the algorithm completely crashes. It works perfectly up until that point but I can't see why it would crash?
void heap_from_root(MVector &v, int i, int n) { int end=n,j=0; // Identify the lowest root and how many sons it has. If it only has one son, set j=1. if (n==1) { n = 0; j = 1; } else if ((n-2) % 2 == 0) { n = (n-2)/2; } else if ((n-1) % 2 == 0) { n = (n-1)/2; j=1; }
I have an existing dialog, having activex control, list control, tree control checkbox, button etc.... I added one radio button and executed the program. whenever i am clicking on the radio button, the dialog hang/crash. Even simply dragging one radio button from toolbox and executing also behaving in the same way.
This compiles fine but when I run the .exe for the first time an error message comes up saying program has stopped working. If I run the program again without recompiling it seems to work as expected.