C++ :: Program Crashes After Input - Terminated Called

Oct 28, 2013

My programs complies and runs. However, whenever i try to enter something when prompt to enter the number of accounts i wanted to create my program crashes.

By the way, im using codeblocks.

it says

terminated called after throwing an instance of 'std:: out of range'. what(): basic_string::substr"

Code:
#include <iostream>
#include "clsInterest.h"
#include "clsDate.h"
using namespace std;

[Code] .....

View 8 Replies


ADVERTISEMENT

C/C++ :: Program Crashes After Numbers Input From User

May 6, 2014

#include <iostream>
#include <string>
#include <limits> //for std: numeric limits
#include <algorithm>
//Function to get an integer from the user that is greater than or equal to zero.

int getPositiveIntFromUser(const std::string& prompt) {
int retVal = -1;

[Code] ....

The first part works, but it doesn't calculate the GCD or LCM at all, it just crashes!

View 2 Replies View Related

C :: Program Is Not Terminated

Feb 26, 2014

I have written the below code,

#include "stdio.h"
int main() {
int c;
while((c=getchar()) != EOF) {
putchar(c);
}
}

The above program is not terminated.how to terminate it?

View 3 Replies View Related

C/C++ :: Train Reservation Program - Declaration Terminated Incorrectly

Dec 8, 2013

//PROGRAM - TRAIN RESERVATION
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<stdio.h>
#include<fstream.h>
#include<process.h>

[Code] .....

View 1 Replies View Related

C :: Recursive Crashes Program?

May 13, 2014

cause I cant find why it crashes. It compiles without any error,but crushes when i run it and I can't find where is wrong the code.

Code:

#include <stdio.h>
#include <time.h>
#include <math.h>

[Code].....

View 7 Replies View Related

C/C++ :: Program Crashes When Try To Remove Item?

Sep 28, 2014

In my program, I am trying to implement a set in which I can add/remove and print, it doesn't have to be a specific value removed just that it removes an item from the list. When I call the removeItem function it crashes, saying my iterator is out of range. I don't understand what is wrong. Here is my code:

#include "stdafx.h"
#include <iostream>
#include <set>

[Code].....

View 4 Replies View Related

C/C++ :: Program Crashes When Records Greater Than 10

Feb 17, 2015

I've implemented a records system for a college assignment and everything works as intended. However upon increasing the amount of records to store in my array above 10, the program crashes upon adding a new employee and I can't work out why...

#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#define esize 10 /* Change max-records */

[Code] .....

View 3 Replies View Related

C/C++ :: Cannot Add New Variables To Program - Crashes After Compiling

Oct 24, 2014

Problem: When I add a new variable to complete my program, it crashes. I have tried tracing where the problem is but it leads to adding new variables

Purpose of program: Every 2 lines of the input file belong to 1 participant. The line with decimals include times a person has run miles. While the second line of each participant are integers that indicate the best sets from workouts the participant had done.

so an example of the output

Participant #1
Cardio Workouts:
Best Time:
Worst Time:
Average Time:
Weight Workouts:
Most Sets:
Least Sets:
Average Sets:

Participant #2
...

Why my program is crashing

#include <stdio.h>
int main () {
// Stats Col0=BestTime Col1=WorstTime col2=mostSets col3=leastSets Col4=Average_time Col5=Average_sets
float chart[20][12], stats[10][6], best_time=100, worst_time=0, most_sets=0, least_sets=100, avg_time, avg_sets, sum;
int i, j;
int p=0;

[Code] .....

Attached File(s)
input1.txt (817bytes)

View 1 Replies View Related

C++ :: Program Crashes While Printing Data From Vectors

Nov 23, 2013

I have a local student and international student class inherit from student class. read and print are virtual functions. After i have set all the member variables when i wan to print out all the student information, my program crashes.

Code: int main()
{
clsUniversityProgram objProgram[3];
for (int x = 0; x < 3; x++)

[Code] ....

View 4 Replies View Related

C :: Program Crashes When Parsing Musical Notes From It

Jul 23, 2013

I have the text parser done, but when I use it, the program crashes. Just because of how I test my code, I know the section where it occurs, but I'm not sure what the exact problem is ( no errors or warning, so it's just something I don't see ). Here is the full code

Code: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

[Code].....

I probably made a mistake in the way I allocated memory or tested values, but I'm not sure where it is in my code. Currently it just prints out "Failed to parse data on line 1" then crashes. Here is the text file I give to this program.

Code:
A#3 500 A#3 500 A#3 500
rest 1000
B#4 500 C3 500

View 7 Replies View Related

C :: Selection Sort Program Crashes Right After Value Entered

Mar 25, 2014

I'm trying to code a Singly-Linked List(Double Pointers) selection sort program and I can't tell what the problem is. My compiler says no errors but when I run the program, it crashes right after I enter the values.

Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

typedef struct node{
int elem;
struct node* link;

[Code] ....

The compiler that I'm using is Dev-C++.

View 2 Replies View Related

C++ :: Fseek - Program Crashes And Stops Responding

Feb 9, 2015

i wrote a little program with fseek. It works good till it reaches the first fseek(). Then it crashes and stops responding.My code:

ifstream inp("myfile.txt");
if(!inp.is_open()) return false;
inp.close();
FILE *f;
fopen("myfile.txt","rb");

[code].....

View 2 Replies View Related

C++ :: Delete Operator Is Not Working - Program Crashes At The End

Jan 12, 2013

int main() {
int vnum = 0;
VEHICLE *vehiptr;
VEHICLE *dptr;
cout<<"Please enter the number of vehicle: ";
cin>>vnum;
vehiptr = new VEHICLE[vnum];

[Code] .....

View 9 Replies View Related

C :: Program Crashes And Returns Random Negative Numbers

Mar 1, 2014

I having some issues with two different programs here... One of them crashes and returns random negative numbers whenever it reaches a "fscanf" function and the other displays a "Polink fatal error: access denied" error.

Code:
/* Evan Wentz */
/* Pike - ET2560 */
#include <stdio.h>
#define MAX_ACCTS 100

int accounts [];
double balances [];

[Code] ....

I thought the reason this kept crashing before was because I didn't type the data into the text file it was writing too correctly, but I made another program to do that, and it crashed whenever it got to fprintf. Program works perfect besides the file stuff...

View 6 Replies View Related

C++ :: Program Crashes When Reading Linked List From File?

May 5, 2013

Why program crashes when reading linked List from file?

#include <iostream>
#include <fstream>
using namespace std;
struct link{
int data;
link* next;

[Code] .....

View 4 Replies View Related

Visual C++ :: MFC DLL To Interact With API - Program Crashes After Displaying 100 Bars?

Apr 27, 2013

I have written a MFC dll to interact with an API and it is run by the target program. the first 100 bars are drawn properly but then the program ceases to operate. I am guessing I have a memory leak but I probably just dont understand what I am doing as I am quite new to programming MFC GDI. Here is my code that causes the trouble...

The variables coming in are commented out to facilitate testing and so it would be displaying the same bars over and over because of this. it worrks for 100 bars, then crashes.

void MainDlg::SS_UpdateChart() {
// the chart plot is completely recalculated each time a new bar is shown
// 300 is plottable height
// 400 is plottable width, 39 bars
int displayChartHeight = 300;

[Code] .....

View 11 Replies View Related

C :: Reversing Every K Nodes Of Linked List - Program Crashes While Running

Mar 11, 2013

The code below is for reversing every k nodes of the linked list. While running the Program it crashes.

Code:
#include<stdio.h>
#include<stdlib.h>
struct node {
int info;
struct node *next;

[Code] ....

View 1 Replies View Related

C :: Write A Program With Two Functions Both Called From Main

Mar 14, 2013

Write a program with two functions both called from main(). The first function just prints "Hello". In the second function ask the user to enter a number. Calculate the square root of the number and return the result to main(). In main() print the square root value.

Code:

#include<stdio.h>
#include<math.h>
float fun3 (float );
main()
}

[code]...

View 3 Replies View Related

C/C++ :: Appointment Scheduling Program - Why Are Destructors Being Called

Mar 5, 2015

I am in a intro C++ class and have an assignment to create a patient appointment scheduling program. I finished my code, but when I run it the destructors in each class are being called a bunch of times and the menu shows up at the bottom of the that, so the whole output looks like a mess. Identifying why the destructors are being called like this?

#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <time.h>
using namespace std;
void ShowMenu ();

[Code] ......

View 11 Replies View Related

C/C++ :: Linked List Delete Function Freezing Program When Called

Aug 12, 2014

My program seems to be working fine, except for when I call on my delete function. I don't receive any errors, but when I call the delete function my program outputs nothing and freezes. As in, my print function (which is called before the delete function) doesn't even work. I've tried removing bits of the function to see if I could pinpoint where exactly the issue is, but I've had no luck.

#include <iostream>
#include <string>
using namespace std;
class List{
private:
struct node{
string _data;

[Code] ....

And the function that is causing me trouble:

void deleteNode(string data){
node* del = NULL;
t = h;
n = h;
while(n != NULL && n->_data != data){

[Code] .....

View 5 Replies View Related

C++ :: Error - Declaration Terminated Incorrect

Aug 6, 2014

PROGRAM:-
#include<fstream.h> //for reading and writing files
#include<conio.h> //for clrscr()
#include<string.h> //for string characters
#include<stdio.h> //for gets and puts function
#include<process.h> //for exit function
#include<iomanip.h> //for setw function
#include<dos.h> //for delay and sleep function

void main()
{ char ch,c=0,che=16;
int i=1,j=16;

[Code] .....

View 6 Replies View Related

C/C++ :: Null Terminated String Function

Feb 12, 2015

how would I write a function that copies a null-terminated string from one char* buffer to another, without using strcpy? I am trying to avoid strcpy because of the null terminator.

Here is my attempt;

#include <algorithm>
#include <iostream>
static const size_t, data_size =32;
struct tString
{
char data[data_size];
};
std::string buffer = strArray1[0] + strArray2[0];
std::copy(buffer.begin(), buffer.end(), tString[0].data);

View 8 Replies View Related

C/C++ :: GDB Core Generated After Application Gets Terminated

Aug 16, 2013

My C++ application gets crashed after throwing the gdb core

"warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff79e54000"

Core was generated by `./server'.
Program terminated with signal 6, Aborted.
#0 0x0000003b67230265 in raise () from /lib64/libc.so.6

View 1 Replies View Related

C :: Counting A Stream Of Non-null Terminated Bytes

Oct 7, 2014

I want to count the number of bytes in a stream that contains nulls. I know I can't use strlen() for this, so is there an alternative?

Code:
char *bytes = "x11x12x13x00x12x13x14x15";

I want to be able to say there's 8 bytes here, not 3 as strlen gives me.

View 3 Replies View Related

C# :: MySQL Exception Connection Unexpectedly Terminated

Jul 10, 2014

I am currently developing a sync module using asp.net. I am getting data from an external database (mysql database) The problem is I am getting the error "Connection unexpectedly terminated" when filling the dataset.

Here's my code

string P_contact = "SELECT A.id, B.firstname, B.middlename, B.lastname FROM Accounts A, Contacts B WHERE A.id = B.id";
MySqlDataAdapter db_P_contact = new MySqlDataAdapter(P_contact, conn);
DataSet ds3 = new DataSet();
DataTable dt3 = new DataTable();

[Code] ....

I am getting the exception on this line of code:

db_P_contact.Fill(ds3, "P_contact");

View 3 Replies View Related

C/C++ :: Error Thrown By Compiler / Identifier Expected And Declaration Terminated Incorrectly

Jan 30, 2015

Error message is identifier expected and declaration terminated incorrectly.

//to define a class Employee
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>
class cEmp {

[code]....

View 7 Replies View Related







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