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
ADVERTISEMENT
Feb 20, 2014
What I am trying do is this in steps,
1)I took an integer
2)I try to convert it into binary by storing the remainder by dividing it in 2, in an integer array size of 8(array1)
3)But the digits are in the reverse order, so I reverse them(array 2)
4)When the number is less like 40 or 20 there are no 8 digits/bits
5)So further manipulation of bits i need to pad some other value(say its 2)in the beginning of the array where you
will have continuous zero bits.
for(k=0;k<8;k++) {
remZ=devZ%2;
devZ=(devZ-remZ)/2;
z_bit_array[k]=remZ;
[Code] .....
I want to pad another bit apart from 1 and 0 until you find one. for example say the content of array2 will be 00010111 then i need it to be 22210111.But my method is not working and make the program non responsive.
View 5 Replies
View Related
Dec 6, 2013
the program is of an address book. the syntax is all fine, and the initial menu of options does show up. but once you punch in the cin, the program just stops.
View 9 Replies
View Related
Feb 22, 2013
I'm having troubles with this program I made. Put it simply, it's a basic program using Queues. Whenever I try to input a value, my compiler(Dev C) suddenly stops working. The .exe file crashes and I've no way on how I can execute my program.
Code :
#include<iostream>
using namespace std;
int *queue;
int rear, front, queueSize;
void enqueue();
void dequeue();
void display();
[Code] ....
View 1 Replies
View Related
Jun 28, 2013
I am trying to write a function to reverse a wav file. The idea is to copy the header as it is from the begening of the input.wav file to the beginning of the output.wav file. After that i have to take count number of bytes(count = numberChannels * bitsPerSample in the wav i use this is 2*16= 32 bits, 32/8 = 4 bytes). With this code i am trying to copy the header( that's working fine) and then copy 10 samples from the end and put them to the output.wav file(after header not at the beginning).
This is the content of the input file:
The last 4 bytes of the header are bolded.
Code:
52 49 46 46 24 bd 01 00 57 41 56 45 66 6d 74 20
10 00 00 00 01 00 02 00 44 ac 00 00 10 b1 02 00
04 00 10 00 64 61 74 61 00 bd 01 00 00 10 00 10
ff 00 10 00 00 10 00 10 00 00 ff 10 10 10 00 10
00 00 00 10 10 10 10 00 00 00 10 00 10 00 10 ff
00 10 00 00 10 00 ff 00
This is the content of the output file it suppose to have in my example
Code:
52 49 46 46 24 bd 01 00 57 41 56 45 66 6d 74 20
10 00 00 00 01 00 02 00 44 ac 00 00 10 b1 02 00
04 00 10 00 64 61 74 61 00 bd 01 00 10 00 ff 00
00 10 00 00 10 00 10 ff 00 00 10 00 10 10 10 00
00 00 00 10 10 10 00 10 00 00 ff 10 00 10 00 10
ff 00 10 00
Code:
void reverse(char **array) {
int i=0;
word numberChannels;//word is unsigned short int , byte is unsigned char
word bitsPerSample;
[Code] .....
The problem is that (having in mind per sample is 4 bytes) instead of copying 40 bytes it just copies 20
View 1 Replies
View Related
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
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
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
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
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
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
View Related
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
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
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
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
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
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
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
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
Jul 30, 2014
I have a simple dialog based app that performs some time consuming file manipulations. The activating method contains the customary
Code:
CWaitCursor wait;
The hour glass initially appears, than after a few seconds, the dialog title bar indicates 'not responding'.
This is misleading to users as it suggests the application has ceased to function when, in fact, it's working just fine. I would like very much to eliminate this 'not responding' message but havn't a clue how to do it. Have any of you dealt with this problem, if so, how?
View 14 Replies
View Related
Jan 25, 2013
The following code results in simple window which stops responding as soon as it is executed.
#include<windows.h>
#include<stdio.h>
#ifndef UNICODE
#define UNICODE
[Code]......
View 10 Replies
View Related
Apr 30, 2014
This is a problem I have been having with every program I write since I started using SDL 2. Whenever I compile my code and run my program, everything works perfectly fine until at some point (usually after 3-8 minutes of running), the program will stop responding completely and I will have to exit out of the console to close it. The code I believe is relevant is:
void MainLoop()
{
InitLoop();
while ( !QuitMain )
[Code].....
If I change SDL_PollEvent(&Event) to SDL_WaitEventTimeout(&Event,100), then the problem goes away (I did that and had the program running for about an hour without it stop responding before I decided that it solved the problem), so I believe that the problem has something to do with event handling. Also, it might be noteworthy to mention that when I use SDL_WaitEventTimeout with the second parameter being a small number (because 100 milliseconds is a long time to wait and makes the program run at like 8 FPS), the problem returns.
View 2 Replies
View Related
Feb 8, 2015
I want to know how to respond to a request made by a mobile application (preferably Android) through a desktop software. So for example if there is a button on the mobile app named 'do something and a user clicks it, I want the desktop software to respond to that request and 'do something
So what I was thinking was to upload a file to a server when the button on the app is clicked and add a timer to the desktop software to connect to the server and read the file and respond accordingly.
Is this how it is usually done or am I going about this the wrong way? Im developing the app in C# (Xamarin) and the desktop software in C# as well.
View 6 Replies
View Related
Jun 19, 2014
As I was testing it, the program suddenly stopped giving an output. Here is the code:
#include <iostream>
using namespace std;
int main() {
cout << "Ten people ate breakfast with you this morning. Each of them " <<
"had pancakes.
Please enter how many pancakes each of the ten people " <<
"ate.
" << endl;
[Code] ...
The while loop after int glutton does not work and seems to stop the program. I replaced the "glutton" in the cout with "testing testing" and it still did not work. However, when I commented out the loop, it appeared. Finally, it can't be what's inside the loop, because I commented that out too, and it still didn't work.
View 2 Replies
View Related
Sep 13, 2013
I am trying to enter data to a structure some 8 times, but not able to do so. Here is my code.
Code: #include<stdio.h>
struct _Timer {
unsigned int HH;
unsigned int MM;
}Time[8];
[code]...
But when I enter any data and press enter , the .exe file stops working and not able to enter data.
View 4 Replies
View Related
Nov 11, 2014
I am currently working on a c++ project that will input students and process their grades. I encountered a problem and my code stops executing after the getScores function. Im not sure what the problem is, but im guessing its something within the function and the loops.
//Name: getScores
//Description: Will get scores for student
//Parameters: None
//Return: testScore
double getScores()
[code]....
View 6 Replies
View Related