C++ :: Finding Multithread Program Error?

Aug 3, 2013

How do I find an error in a multithreading program (written in C)? I get an address, but when I put it into psp-addr2line, i get

??
??:0

View 2 Replies


ADVERTISEMENT

C :: Writing Log File In Multithread Program

Oct 20, 2014

I'm currently finishing writing some small application. I want to be able to log important information about the program execution to a logfile, and I have several questions.

First of all - I'd prefer to make the part that logs information to a file separate from the code I've already written. So, what interface should I expose to the rest of the program? Is one function void log(const char*); enough?

Another thing that came to my mind; my program runs two threads, and I want to be able to write to the log file from both threads, so the question is: Should I make sure that the writing to the file is mutually exclusive?

And if so, whose responsibility is it to make the logging to the file thread-safe? The actual part that does the logging (void log(const char*) for that matter), or the parts of the program that calls log(const char*) ?

And lastly, and probably less importantly, where is it customary to save the logfile? (the user's home folder maybe?)

View 3 Replies View Related

C :: Finding Error In Delete Node Function

Sep 12, 2013

I have written a delete node function to delete a node in a linked list by the index number. Here is the code:

Code:

void delete_node(struct node **start,int index_no)
{ int counter=0;
struct node *current=*start, *prev=NULL;//Current holds start and prev holds previous node of current
while(current->next!=NULL)

[Code]....

note that I know if the head node turns out to be the indexed position, there is no way to delete that node in the current coding. But please after correcting the present node add that part of the code separately.

View 5 Replies View Related

C# :: How To Multithread Port Scanning App

Jan 24, 2012

I'm creating a small port scanning app which use a port range defined by user.My problem with the code is that I find it not efficient enough meaning that it ping very slow, especially when ports are not responding meaning that I must wait for the timeout before continuing to next port.

I want to make this small app threaded. The problem here is that I'm kind of blank of how to implement threading in my program. This is my code which is a method which does the actual checking, the other part of the code is a simple button with for loop for advancing my port number.

Code:

private void ScanPort(IPAddress address, int port) {
using (TcpClient client = new TcpClient() {
IAsyncResult result = client.BeginConnect(address, port, null, null);

if (result.AsyncWaitHandle.WaitOne((int)nudTimeout.Value, false)) txtDisplay.AppendText("Port: " + port + " is open." + Environment.NewLine);
else txtDisplay.AppendText("Port: " + port + " is closed." + Environment.NewLine);
} }

I have read some basic threading tutorial but I just don't know how to implement this piece of code so I can check ports much faster.

View 3 Replies View Related

C++ :: How To Multithread Socket Serve

Feb 19, 2013

I'm having a bit of trouble learning how to multithread a socket server. I have everything working perfectly fine, but it only accepts one client (I would like multiple clients). some sort of example (I have troubles understanding some things, unless its visual).

View 4 Replies View Related

Visual C++ :: Error In Finding Lowest Double In Array

Oct 25, 2014

When I run the program, when it displays the lowest temtpature, it shows the address instead of the actual number.

Code:
/*********************************************
* File: b.cpp
* Description: Create a C++ program that declares a 100-element array of doubles representing temperature readings. Pass the array to a function to be partially filled by the user. When the user is done entering temperatures, the function should return the number of elements added to the array. The main function should then display the maximum and minimum temperatures in the array.
***********************************************/

#include <iostream>
using namespace std;
//prototypes
void getData(double arr[]);

[Code] ....

View 2 Replies View Related

C# :: MultiThread Blocking Updates During Read

Oct 6, 2014

I have a class holding my data strcuture:

// Holding real time option data - should be thread safe
public class OptionRTHolder {
ConcurrentDictionary<double, Quates> book_calls;
ConcurrentDictionary<double, Quates> book_puts;
ConcurrentDictionary<double, List<Single_qoute>> transaction_calls;
ConcurrentDictionary<double, List<Single_qoute>> transaction_puts;
ConcurrentDictionary<double, int> volume_calls;
ConcurrentDictionary<double, int> volume_puts;
DateTime curr_time;
}

I get a stream of data messages, that come in order, each message carries a time and data. I have many threads in paralell pulling messages and in turn update the data strucutre as follows:

Quates and volume data are just overrun (new value overrun former values), also thier size and meta data is fixed (they don't grow post init).

Via the list I have a problem, I would want to lock only the list I am working on. so other lists can update in paralell, what I had in mind was to warp the list in order to warp the add/get calls to make it thread safety, this I think will achieve this goal and I would like to get some assertion from this forum if you may.

Here come my real problem, there are points in time I want to read/copy this structure, during this time I want to block all updating threads as I want to freeze structure in time, is that achiveable ? Idea that I had is to use something like aquire that will get a function (update/read) and a flag that will cause a lock when the read is on...something like that.

View 3 Replies View Related

C++ :: Multithread Application - Global Dynamic Array

Nov 18, 2013

Let's have global dynamic array p defined as

volatile int p[];

Let's use it in a multithread application, where every thread can change array's size by

new_p = realloc(p, new_size);
if (!new_p) exit 1;
p = new_p;

For simplify assume that we have no problems with it's size and indexing.

Expression like

int x = p[i];

is unsafe cause thread (1) takes the pointer and (2) add the index. Executing of this thread may be stoped after first step before second step. In this time other thread can realloc the array, which move it to some other place in memory. Executing second step after it will add index to wrong pointer. So we will have segmentation fault.

View 2 Replies View Related

C :: Program Finding Max Of Graph

Oct 29, 2013

this is my first year programming, and in my class, each week we have to write a program. last week we wrote a program in c that made random value point and made a graph of the random points that continued on forever. this week, we have to use statistical functions to find the sum, mean, max, and min of the graph. below is the code i have so far.

Code:

#include <stdlib.h>
#include <strings.h>
#include <stdio.h>
#include <stdbool.h>
#include "SwinGame.h"

[code]....

so, as you can see from the code, the parts i need are finding/ coming up with a function to find the max min sum and mean of the functions.

View 7 Replies View Related

C/C++ :: Finding Type Of Variable Given In Program?

Jul 25, 2012

for ex: say i'm declaring two variables under int type and some 3 under char,my output should be lyk this: 2 variables in int and 3 var of type char...(input to the main program is actually another program where these 2 int and 3 char are defined).

View 1 Replies View Related

C++ :: Finding Program That Calculates Student Grades?

Jun 7, 2013

I have to make a program that reads two student grades, the average of the two has to be 6, if you can not take an average of 6, will make a third test and calculate a new average.

I'm not getting the new display medium, without repeating the approved and disapproved?

// TRABAV2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {

[code]....

View 1 Replies View Related

C :: Finding Percentages / If Statement / Clear Screen And Reloading Program

Nov 11, 2013

For my C programming module, I've been asked to create a program which is basically a ten question mathematics quiz or test if you like. Below is a copy and paste of my current, working program.

Code:

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

[Code]....

I am also trying to include into my program; If the user achieves 4 or less marks in the test, they are asked if they would like to repeat the test (have a second chance).

I have been asked by my Lecturer to ask the Question; "Would you like to try again" and the response is 'Y' for yes, 'N' for no. Would this be shown by:

char Y = Y;
char N = N;
printf("Would you like another go?");
scanf(%d%, &Y, &N);

And finally; If the user would like another go, then I am trying to include the code that clears the screen and then reloads the program?

What code is used to clear the screen and no clue what code is written to refresh or reload the program. I assume it's a loop statement or some sort.

View 1 Replies View Related

C/C++ :: Can't Run The Program Because Of Error

Nov 15, 2014

my code is :
#include<stdio.h>
int main();
{
printf("????
");
return 0;
}

error: expected identifier or '(' before '{' token
what do I have to do to run it?

View 1 Replies View Related

C/C++ :: Error When Trying To Program BMI Calculator

Aug 26, 2014

'm trying to program a BMI calculator in C for my assignment where the weight must be in KG and an int , and the height must be in m and a double value. The program should allow the user to input his weight(kg) and height(m) separated by a space and be able to calculate and display the BMI. My code is shown below :

#include<stdio.h>
int
main(void) {
int weight;
double height,bmi;
bmi = weight / ( height * height ) ;
scanf("%d%lf" , &weight , &height );
printf("BMI = %f", bmi);
return 0;
}

However , after running the program , I constantly get a 1.#INF00 value for my result.The compiler did not show any errors so why I'm getting this value.I input my weight and height in this format "45 1.65" 45 being the weight and 1.65 being the height.

View 3 Replies View Related

C/C++ :: Encryption Program Error

Aug 5, 2014

Back again with a random bug that I can't seem to track down. My error is in my main.cpp file. I get a C2248 error on line 54, there I'm doing:

t.makeEmpty(t.root)

I know why, because it's a private member...but it should have access in so far as everything is concerned. I double checked my makeEmpty code and it's good to go so far as I can tell. I can't quite iron out where the disconnect is.

V/R
Brad
main.cpp
#include <iostream>
#include <string>

[Code].....

View 4 Replies View Related

C++ :: Open Program Error Notification

Mar 23, 2013

I've almost finished a Terminal/Command Prompt Program that can do most of the things a Microsoft or Linux Terminal can do - but I have a problem. I've got it to open programs fine, and I can also open their browser to the download page if they don't have it, but I need my program to know if there isn't the software so a bit like command prompt where it says 'The system cannot find the file test.txt.' and then it'll take them to the website if they like.

View 2 Replies View Related

C :: Array Program - Parse Error Before INT

Sep 18, 2013

this program is just to give the size and value of the array by the user.

Code:
#include <stdio.h>
main( ) {
int size ;
scanf ( "%d", &size ) ;
int arr[size] ;
for ( i = 1 ; i <= size ; i++ ) {
scanf ( "%d", arr[i] ) ;
printf ( "%d", arr[i] ) ;
}

error : Code:
C:UsersDocumentsprog est.c:7: parse error before `int'

View 7 Replies View Related

C++ ::  Error In Prime Numbers Program

Jan 29, 2013

Here is what I have:

#include <iostream>
#include <cmath>

using std::cout;
using std::endl;
using std::cin;

[Code] .....

This is the output after compiling when I enter 10 as 'x':
3
5
5
5
7
7
7
7
7
9

View 1 Replies View Related

C++ ::  Palindrome Program Compile Error

Jan 16, 2014

Here is the code which I wrote in Turbo C++...its giving errors..

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
voidmain() {
clrscr();

[code]....

View 8 Replies View Related

C++ :: Payroll Program - Calculation Error?

May 22, 2014

I'm working on a payroll program and I'm having problems that are causing calculation errors.

My input file is
1234FredJones4025.00
2345 TerrySmith6010.00

The errors I get are from the regular pay, over time pay, gross pay, tax amount and net pay calculations. They all look similar to this (6e+002). I believe they are occurring because regular pay isn't calculating correctly and the rest depend on that for their calculations. However, I can't see why regular pay isn't calculating correctly.

#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
class payroll{
ifstream fin;
char employeeid[100];

[Code] .....

View 14 Replies View Related

C++ :: Getting Error In Karatsuba Multiplication Program

Oct 5, 2014

I have made a Biginteger class that performs multiplication operation according to Karatsuba's algorithm. But it seems that the code is not working perfectly.In the class I have made a function named karatsuba(BigInteger a1, BigInteger b1)that performs the Multilplication operation. There might be problems in this function as I have tried to store the original digits(neglecting the leading zeros) of the two big integer values into two integers or there might be problems in somewhere else. corrected version of this function? My code is given below:

#include <stdio.h>
#include <iostream>
#include <cstdio>

[Code].....

View 2 Replies View Related

C/C++ :: Getting Error In Karatsuba Multiplication Program?

Oct 5, 2014

I have made a Biginteger class that performs multiplication operation according to Karatsuba's algorithm. But it seems that the code is not working perfectly.In the class I have made a function named karatsuba(BigInteger a1, BigInteger b1)that performs the Multilplication operation. There might be problems in this function as I have tried to store the original digits(neglecting the leading zeros) of the two big integer values into two integers or there might be problems in somewhere else.My code is given below:

#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
#define MAX_DIGIT 100

[code]....

View 5 Replies View Related

C/C++ :: Two Numbers Relationship Program Error

Aug 15, 2014

I write below two numbers relationship program and got below error.

//two numbers relationship
//take standard and console input and output
#include <stdio.h>
#include <conio.h>
//take function main
main()

//define numbers {
int num1; //first number
int num2; //second number

[Code] ....

View 3 Replies View Related

C++ :: QTCreator Finds Error Outside Of Program

Sep 20, 2014

Code:

#include <iostream>
#include <vector>
using namespace std;
struct Child;// incomplete type
struct Parent {
string name;
vector<Child *> children;// we don't need to know the details heres

[Code] .....

Why this program wont compile?

View 3 Replies View Related

C++ :: Compiled Program Error Win32 Invalid

Nov 30, 2013

I am using visual studio 2012 on windows 7. but, when I have compiled my programs and run them on an older pc to test out its functions, I receive an error saying that the program is not a "valid win32 application." I have even tested this with a very simple hello world console application, but the problem still remains. Where is the error coming from? is the application corrupted during transport? (upload to internet) or are programs compiled on win 7 incompatible with win xp

View 6 Replies View Related

C++ :: Insertion Sort Program - Runtime Error

Apr 11, 2013

I am trying to run this program for Insertion Sort, But some how I am getting some problem:

#include<iostream>
int main(){
int i,j,key,n;
scanf("%d",&n);
int a[n];

[Code] .....

Error
In function 'int main()':
Line 10: error: ISO C++ forbids variable-size array 'a'
compilation terminated due to -Wfatal-errors.

View 2 Replies View Related







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