C++ :: Running A Procedure Repeatedly After A Set Time Interval

May 28, 2013

I have a certain piece of code that I want to run every 2 minutes. One of my ideas is to get the time and modules that with whatever number represents 2 minutes. Would this work?

View 4 Replies


ADVERTISEMENT

C++ :: Program Which Allows A User To Enter Input For A Time Interval

Apr 23, 2014

how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...

View 4 Replies View Related

C# :: Running A Class At Design Time

Aug 7, 2014

I have a Class called 'DataManager' which contains a list of my 'DataItem' objects (this are created by an XML file).

I have also created some custom controls which, among other things, has a property to link it to a "DataItem" object.

My question is, is it possible to create an instance of my DataManager class at design time (which runs all the code as it would at run time to create all the DataItems from the XML)?

I want to do this so that I can update my DataItem property in my custom controls to use a UITypeEditor which then allows me to link to a DataItem at design time.

View 4 Replies View Related

C++ :: Identify End Of Function Code At Running Time

Apr 16, 2013

I want to implement some "debugger like" tool (very limited one, just identify at running time the current stack trace, and print messages from the user) on some code that the user wrote. what I get from the user is a function name (in the beginning of it's declaration), and when the user want to print some message he uses some print macro I should implement.

My target is printing the stack call, and all the messages that the user wrote, in the right place on the running place.

By what c++ feature can know on running time that a specific function code has ended??

Its easy to push a function to some vector when it called (since I get its name from the user), but when it ends and return to the function called it...

View 14 Replies View Related

C++ :: Chat Messenger - Running Multiple Threads At Same Time

Sep 18, 2013

I'm doing work on chat messenger and facing difficulty to run multiple threads at the same time. Here is the sample code.

void menu();
void groupChat();
void personalChat();
int main() {
sf::Thread thread(&menu());
thread.launch();

[Code] ....

In my program, after menu when he selects a choice, next display of menu wait the termination of the selected thread.
while i want to show menu right after when a menu is selected.

View 2 Replies View Related

C++ :: Measure Sorting Algorithm For Performance In Terms Of Number Of Steps And CPU Running Time

May 13, 2014

I have an school assignment that asks me to measure the most famous sorting algorithms for performance in terms of number of steps and CPU running time. ( Here I'm testing for running time)

I decided to test for bubble sort first:

#include <iostream>
#include <ctime>
using namespace std;
void bubbleSort(int ar[], int size) {
int temp;

[Code] ....

So basically what I want to know is:

1. Is this clock function giving the correct CPU running time?

2. Is there any way to write code that would measure the number of steps for each algorithm?

3.I need to test it for number of integers=100 then 200, then 300... Well you get my point, and I don't want to have to actually input 200 numbers with my keyboard. Is there any way to generate as many entries as I want?

View 4 Replies View Related

C++ :: Assign Value To Interval

Oct 2, 2014

This is my code , i should Assign value val to interval [keyBegin, keyEnd).

#include <assert.h>
#include <map>
#include <limits>

void assign( K const& keyBegin, K const& keyEnd, const V& val ) {

if(!(keyBegin<keyEnd))

[Code] .....

View 7 Replies View Related

C/C++ :: A Program That Repeatedly Reads In Values?

Sep 26, 2014

I started to write a program that repeatedly reads in values for a,b and c and find the root of the polynomial

ax^2 + bx + c = 0

The program should print out for example:

two complex roots: root1 = -1.00000 + i*1.41421
root2 = -1.00000 - i*1.41421

My code:

#include <stdio.h>
#include <math.h>
int main(void){
int a,b,c;
printf("Choose the values of a, b and c for the equation ax^2 + bx + c");
scanf("%d%d%d
",a,b,c);

[code].....

View 6 Replies View Related

C++ :: Simple While Loop - Prints Out Number 10 Repeatedly

Apr 30, 2014

I know for while loops you type

while(argument){
do whatever
}

you have to use the brackets to enclose just like I used in my code right here.It is a simple while loop that is a countdown.

#include <iostream>
using namespace std;
int main() {
int n =10;
while(n>0){
cout << n << ", ";

[code].....

when I take the brackets away from my while loop, my code will still execute but it just prints out the number "10" repeatedly. I was just wondering why it does this and why the compiler does not throw out an error when I leave off the brackets after the "while()".

View 10 Replies View Related

C++ :: Performance Penalty For Repeatedly Dereferencing A Pointer?

Oct 2, 2013

Let's assume "person" is a class that has a member "age", and personptr is a pointer to a person object.

doStuff(personptr->age);
doMoreStuff(personptr->age);
andSomethingElse(personptr->age);
andSomethingElse(personptr->age);

Is this bad for performance? Is the following better or doesn't it matter?

int person_age = personptr->age;
doStuff(person_age);
doMoreStuff(person_age);
andSomethingElse(person_age);
andSomethingElse(person_age);

View 2 Replies View Related

C++ :: How To Cut Off Input When Using Getch - If User Repeatedly Presses Key

Nov 29, 2013

I am asking for input for a char by using the _getch() function. The thing is that when a key is pressed multiple times it screws the program because it executes every single key that is entered.

I am asking for the user to enter a letter that will determine an action to be used in battle, like attack, magic, "use item", etc.

char option;
cout<<"Enter your choice for battle: ";
option=getch();
if(option=='a')
//Executes an attack
else if(option=='b')
//Opens magic menu
else if(option=='c')
//Opens item menu

Suppose the user enters a character, then the program executes an action by the enemy monster. This is where the problem arises, if the user entered multiple keys or if he enters input during the time the monster attacks, the next time it is the user's turn it will execute the first attack automatically because it keeps reading the input.

I want to know how to cut it off, so that it doesn't ruin the program like that.

View 7 Replies View Related

C/C++ :: Number Of Twin Primes Between Interval?

Feb 11, 2015

I'm having some trouble finishing my code, it's meant to give the number of twin primes between an interval e.g. 1 to 1000000 and the answer should be 8169 but all I can get it to is 8168

#include <stdio.h>
int prime (int num) {
int div;
if (num == 2) return 1;
if (num % 2 == 0) return 0;
div = 3;
while (div*div <= num) {

[code]....

View 6 Replies View Related

Visual C++ :: Finding Temperature At The End Of Interval But Can't Seem To Get Answer?

Oct 30, 2013

I've been trying to get the numbers for hours now but i can seem to get it right. Here's the problem below:

During the initial period, when the heater is not yet functioning at peak efficiency the heating will increase the temperature inside the building at a rate given by the following equations. During the initial period when the air conditioner is not yet functioning at peak efficacy the air conditioner will decrease the temperature inside the building at a rate given by the same equations.

Interval = (Time since turning on / 2.0 ) - 3.0
Factor multiplying Temperature change per minute = exp( Interval) / ( 1 + exp(Interval) )

These equations can also be used after the heating or air conditioner reaches peak efficiency. These equations converge to 1, so after the heating or air conditioner reach peak efficiency these equations will always give a value of 1.

the value of these equations needs to be multiplied by the RATE TEMPERATURE CHANGES. The RATE TEMPERATURE CHANGES is EITHER the change in temperature inside the building in degrees Celsius per minute caused by heat being extracted by the air conditioning OR the change in temperature inside the building in degrees Celsius per minute caused by the heat being generated by the heating .Temperature change in degrees per minute = Factor multiplying Temperature change per minute * RATE TEMPERATURE CHANGES

Temperature at end of this interval = Temperature at the start of the interval + temperature change due to heat escaping during the this interval + temperature change due to heat generated by the heating system during this interval + temperature change due to heat removed by the cooling system during this interval

i have a:

...rate of -.05 for heat escape w/o cooling or heating
...rate of 0.10 for heat escape w/ cooling
...rate of 0.125 for heat increase w/ heating
...Starting temp=38.00
...Time interval 3.50

I can't seem to find the temp at the ending interval? What i tried doing:

Code:
#include<iostream>
#include<cmath>
using namespace std;
int main () {
double intervals=0.00;
double tempPerMin=0.00;

[Code] ....

The temperature at the end of the interval is suppose to be 37.81 but i can't get the answer. I'm pretty sure this is a logical error from the equations i used but i can't seem to find it.

View 3 Replies View Related

C :: Generate Pseudo Random Real Number From Interval (0,1)

Feb 6, 2013

How can I generate a pseudo-random real number from interval [0,1] ?

Can it be generalized to any interval? Like [0,a], where 'a' is a parameter?

I tried searching for it, I only found rand(), srand(), random(1), and randomize. None of it actually seems to work for me..

Later I actually succeeded with something like

srand( (unsigned)time( NULL ) );
printf( " %6d
", rand() );

but it only produces up to five digits integers and I cannot divide by 99999 to get it into [0,1].

View 11 Replies View Related

C++ :: Generate Numbers For A Binomial Coefficient From Number Interval

Mar 27, 2013

I'm trying to write a code which will generate numbers for a binomial coefficient from a number interval [2-10], i think it should look like this:

n=2
r=2
n=2
r=3
n=2
r=4
n=2
r=5
.
.
.
n=10
r=10
-The program should stop here.

This is badly written, but it still has the basic idea in it.

#include <iostream>
using namespace std;
int main () {
int n=2;
int r=1;

[Code] ....

View 1 Replies View Related

C++ :: Allow User To Select Repeatedly Operation To Be Performed From Displayed Menu Of Actions

May 1, 2013

Write a user-friendly C++ program that allows a user to select repeatedly an operation to be performed from a displayed menu of actions. The menu includes the following items:

1. Simple Statistics
2. Vector Addition
3. Dot Product
4. Exit

The menu actions are described by the following points:

Simple Statistics: This action includes finding the average, and standard deviation of a list of data items. The option should allow the user to specify the name of a file from which the data are read into an array. All the results of this option are displayed on the screen.

Vector Addition: This action allows the user to enter the name of a file from which two vectors, V1 and V2, of equal size N are read. Accordingly, the two vectors are added, and displayed along with the resultant vector on the screen. Your program should check that the two added vectors are of the same size. Otherwise, the program should display a message and allow the user to make another choice from the menu.

Dot Product: This action is similar to the Vector Addition in terms of input, output, and checking validity of the vector operands.

Exit: This action terminates the program.

Your program should include at least the following functions:

1. A function, called ReadVector(), which reads a vector of any size from a given file name, and returns the vector and its size to the caller. The function prototype is defined as follows:

void ReadVector(double V[], int &size, ifstream infile);

2. A function, called DisplayMenu(), which displays the menu and returns the user’s choice as an integer value between 1 and 4. The function prototype is defined as follows:
int DisplayMenu (void);

3. A function, called VectorAdd(), which performs the addition of two vectors, A and B, and returns the resultant vector, C. The function prototype is defined as follows:

void VectorAdd(const double A[], const double B[], double C[], int size);
The sum of two vectors, A = (a1, a2, …, an) and B = (b1, b2, …, bn) of size n, is defined as: C = A + B.
Where, C = (c1, c2, …, cn), and ci = ai + bi, for1 i n .

4. A function, called DotProduct(), which performs the dot product of two vectors, A and B, and returns the result. The function prototype is defined as follows:

void DotProduct(const double A[], const double B[], int size, double &result);
The dot-product of two vectors A = (a1, a2, …, an) and B = (b1, b2, …, bn) of size n is defined as
n n
n
i
i i b a ....... b a b a b a B . A  
1 1 2 2
1

5. A function, called Simple_Stat(), which finds the maximum, minimum, average, and standard deviation of a list of data items passed to it by a one-dimensional array. The function returns the average and standard deviation values. The function prototype is defined as follows:

void Simple_Stat(const double list[], int size, double &average, double
&std_dev);

View 1 Replies View Related

C# :: How To Using Stored Procedure With Web Grid

Apr 9, 2014

How do you use a stored procedure with a WebGrid? Our coding standard say we cannot write sql statement directly in the code to include HTML.

[var Grid = new WebGrid(DB.Query("Select * from Menu")]

The above call must be a call to a stored procedure.

View 4 Replies View Related

C Sharp :: Procedure Or Function Has Too Many Arguments Specified

Apr 1, 2014

I have a button that calls a delete stored procedure with only two parameters. I can run the stored procedure via SQL manager and know it works. But, when I call the stored procedure from a sqldatasource on the .aspx page I get this error: Procedure or function has too many arguments specified.

Here is my code:

<asp:SqlDataSource runat="server" ID="sqlAuthorsInfo" ConnectionString="<%$ ConnectionStrings:Authors %>" 
ProviderName="<%$ ConnectionStrings:Authors.ProviderName %>" 
SelectCommand="FindAuthors" SelectCommandType="StoredProcedure" DeleteCommandType="StoredProcedure" 
DeleteCommand="Remove_Authors">
    <SelectParameters>

[Code] ....

Here is how the stored procedure looks - it is very simple:

DECLARE @authorcode int, @authorid int  
DELETE FROM Requests
WHERE authorcode = @authorcode
AND authorid = @authorid  

What is wrong? How do I resolve this???

View 1 Replies View Related

C++ :: How To Convert Write Procedure To Cout

Aug 18, 2013

I'm building a Console class(i realy need it). and i don't understand how can i build the Write() procedure. Heres the structure:

write(varname1[,varnamex])

how can i convert it to cout?

View 14 Replies View Related

Visual C++ :: Prompt New File Procedure

Mar 12, 2014

I currently have a program where, by either pressing Ctrl+N or by going to "File->New" in the menu a new file is prompted.

However, there are cases in my program where I would also like the "new file" protocol to be called when a user presses a button.

Is there some way of accomplishing this, or can the "new file" protocol only be called by the standard Ctrl+N or "File->New" calls?

View 4 Replies View Related

C :: DLL Error - Procedure Entry Point Could Not Be Located

Oct 22, 2013

I hope that this isn't an elementary question to you more experienced people, but I am having some trouble with my .DLL file. I haven't ever had a problem with compiling and linking it with my main project before, but it appears now some sort of problem has started. The message that appears is :

I have no qualms with posting my .DLL source, as it is not particularly long or complex. It seems the problem functions are the last two I've added ( load_sound( ) and play_sound( ) ).

Here is what I'm linking it with :

Code:

-------------- Build: Debug in game (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -shared -Wl,--output-def=binDebuglibgame.def -Wl,--out-implib=binDebuglibgame.a -Wl,--dll -L"F:FBLARandom gamegame.dll.sourcegame" objDebugconversion.o objDebugprojectile.o objDebugSDL_utility_functions.o objDebug ime.o -o binDebuglibgame.dll -lSDL -lSDL_mixer
Creating library file: binDebuglibgame.a

Output size is 49.10 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds) projectile.c :

Code:
#include "game.h"
#include <stdio.h>
#include <stdlib.h>

/* ******************************************************** */
/* ********* create( ) ********* */
/* ******************************************************** */
/* - Allocates one node of type projectile on the heap, */
/* and returns its' address */
/* ******************************************************** */

[Code] ....

View 6 Replies View Related

C# :: Extract Value From Stored Procedure That Takes A Parameter

Dec 17, 2014

I have a stored procedure, which I cannot change (it is used by older programs). It is passed an int of 15 and then an ID is generated and written to a database table. The created ID is then suppose to be selected and returned.

The INSERT does not seem to be working. I'm not getting the created ID value from my code, I am getting the value I passed to the procedure when I get to this

line of code "sessionID = sessionProcedureID.Value.ToString()";.

Below the stored procedure and my code.

/***************Stored Procedure***********************/
USE [testDataBase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[MakeValue]

[Code] .....

View 14 Replies View Related

C# :: Using Dataset Result As A Variable In A Stored Procedure

Aug 6, 2014

I'm trying to pass one dataset's result as a variable in another stored procedure and this is what I have so far:

DataSet dsID = StoredProcedures.GetID((int)Session["TypeID"]);
int IDValue = Convert.ToInt32(dsID.Tables[0].Rows[0]["ID"]);
DataSet dsRequest = StoredProcedures.GetRequest(IDValue);

But I get the error: cannot implicitly convert to system.dataset.

View 1 Replies View Related

C/C++ :: How To Retrieve Stored Procedure Functions In Program

Oct 3, 2012

Stored procedure functions about c program

View 1 Replies View Related

Visual C++ :: Procedure To Compare 2 Strings With Specific Criteria?

Jul 10, 2013

Procedure to Compare 2 Strings with the following criteria

coding of the following function -

I have absolutely no clue where to start -

Given the following sets of numbers -

1154 1179 2154 2554 2484 2144 4515 1144 1517 4815 1481

Given the Index number of 1154

I want to search the numbers for the Index number of 1154

The search will return a True if I can find 3 or 4 same digits between the Index number and the 8 numbers

The search also have the following criteria -

meaning that -

1154 when compared to 1154 == true
1154 when compared to 1179 == false
1154 when compared to 2154 == true
1154 when compared to 2554 == false
1154 when compared to 2484 == false
1154 when compared to 2144 == false
1154 when compared to 4515 == true
1154 when compared to 1144 == true
1154 when compared to 1517 == true
1154 when compared to 4815 == true
1154 when compared to 1481 == true

the index number can also be of type - 1234, 1123, 1112, 1111

View 14 Replies View Related

C Sharp :: Windows Service To Call Stored Procedure Every 30 Days

Jul 24, 2012

Just now I started learning Windows services.I want to create a windows Service that will call the stored procedure every 30 days.

View 1 Replies View Related







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