C :: Application That Uses Two Different Timing Techniques

Feb 19, 2014

I am looking at a same application in c that uses two different timing techniques. One involves the nanosleep() function which suspends thread for given nanoseconds. The other one uses a combination of gettimeofday() which returns number of microseconds since epoch as a start value. Then it uses var counter of for loop as max value. And it uses ellapsed time for each call of gettimeofday in microseconds in a do while loop to increment diff, until diff is not less than var. Why would someone choose to use this timing techinque be used instead of nanosleep?

Code:
unsigned long getTime() {
struct timeval detail_time;
gettimeofday(&detail_time,NULL);
return (detail_time.tv_usec);

[Code] .....

View 1 Replies


ADVERTISEMENT

C++ :: Optimizing Timing Functionality?

Jan 18, 2013

I've written a timer function in c/c++, but it still has performance problems. how to optimize this further (atm works with delay to perform timing):

#include "headers/types.h" //Basic types!
#include "headers/timers.h" //Timer support function data!
#include "headers/emu/threads.h" //Thread for timer item!
//Timer step in ms! Originally 100ms
#define TIMER_STEP 10000

[code]....

View 3 Replies View Related

C++ :: Timing Function - Sort Dynamic Array With N Elements

Apr 11, 2014

I'm writing a program that will implement BubbleSort and MergeSort and time them as they sort a dynamic array with N elements. These are the instructions on what my main.cpp file should do.

main.cpp
Include all needed libraries for timing and random number generation while the number of element, N, is less than 100001 repeat the following.

create an array with N (initially 10) random elements
sort the same array with Bubble and Merge sort
time how long it takes each algorithm in microseconds (see example below)
Increase N by a factor of 10 (N *= 10)
Hint: you may want to put your merge sort object on the heap and delete it with every iteration of this loop

And this is what I have so far for my main.cpp

#include <iostream>
#include <sys/time.h>
#include <ctime>
#include <cstdlib>
#include <stack>
#include <iomanip>
#include "BubbleSort.h"
//#include "MergeSort.h"

[Code] .....

One of the errors that I'm running into is that I'm not sure how to correctly call the function I think?

View 3 Replies View Related

C# :: Server Application Using Tcp Protocol And Then Establish Connection With A Client Application

Nov 29, 2014

What happens if I make a server application using tcp protocol and then establish connection with a client application but the server crash and then the client send data. Will the data be lost or the system will continue trying to send it?

View 2 Replies View Related

C# :: How To Start Application And Automatically Pass Input To That Application

May 9, 2012

I want to create an application that starts an application and passes input to that application. I know how to start a process using the classes in System.Diagnostics, but I don't know how to pass data to the process.

For example, and this is just an example, I would like to be able to automatically start an application that requires a username and password and automatically enter the username and password. Of course, that might open the door to security vulnerabilities, but that's not the point of the exercise.

How to implement the functionality I described? Is there a general way to go about doing this or does it depend entirely on the idiosyncrasies of the application in question?

View 2 Replies View Related

C Sharp :: Run Application When Log Off In Console Application

Oct 4, 2012

i have task scheduling application which execute every 30 minute i want to keep this process when system is log off in c# console application

View 2 Replies View Related

C++ :: How To Input PNG Into Application

Jan 6, 2014

Is there any way to input a picture into an application? I want to make the console of my C++ program display an image across it for a short while. The picture in mind is a gif. If there is no way to make it display in the console, is there a way to make only the image and not the webpage pop up on the screen?

I am trying to replicate the Skyfall "M gets hacked" scene. But this would be useful for other purposes as well.

I am not familiar with using header files or any other files other than the .cpp file and I only use one .cpp file for all my programs.

View 7 Replies View Related

C++ :: Web Service In Application?

Aug 26, 2012

I am using an increasing number of applications which can be serviced from a web page. These apps do not need tomcat, apache or IIS to be installed but they are able to serve out web pages on demand.

Question is how is this done? Is it just a thead polling a port, waiting for a mime message and then chucking out the content or is it something more complex than that?

View 3 Replies View Related

C++ :: Converting Strings In Application

Jun 8, 2014

I am having trouble converting strings in my application.

This is the code that is eventually getting called, the first parameter takes a LPCWSTR

Code:
hr = m_pGraph->RenderFile(m_filePath, NULL); // takes LPCWSTR This is where the trouble begins.

The compiler shows that sResult is proper but after I try to convert a std::string to a wchar it prints garbage

Code: const wchar_t* m_filePath = (wchar_t *) oDb->GetNext().c_str();

Code:
std::string CSqlLiteDatabase::GetNext() {
sqlite3_stmt *oStmt = nullptr;
std::string sql = "SELECT path || filename FROM table WHERE id = 1";
char message[255];

[Code] ....

View 6 Replies View Related

C :: How To Send A String To C# Application

Apr 1, 2014

i developed 2programm that the first one is in C and the second one is in c#.and now i have to send some string text from c to c#.how can i do that in c ?

View 8 Replies View Related

C :: Changing Program To Application?

Aug 22, 2014

I was wondering if there was a possible way to change my c program into an application so that i can send the application to another person and not let the other person have access to my codings?

My reasons for asking this question: For the application i want to send there are secrets that are meant to be unraveled by gameplay but i dont want people to look at the codes and know everything.

View 6 Replies View Related

C++ :: Adding UI To Console Application

Apr 6, 2013

Any tutorials on adding a UI to a console application? All I really need is a button that will run one function every time I click it.

View 1 Replies View Related

C++ :: Make Logger For GUI Application?

Sep 12, 2014

I'd like to make a logger for my GUI application. I currently use std::cout and std::cerr, but I'd like to replace these with an arbitrary buffer which isn't connected to stdout or stderr. My requirements are:

1. On the user-side, the usage should be identical to any ostream object (including support for std::endl).

2. When std::flush is received, it "signals" my logger so I can run this line of code:
LogWindow->setText( mybuf.str() )

I think I need to extend a std::basic_stringbuf<char>, but which virtual method do I need to implement in order to print to my custom window?

My first attempt is this. I'm testing with std::cout, but the output is empty and running in the debugger doesn't trigger a breakpoint in my sync() method.

#include <ostream>
#include <iostream>
class MyBuffer : public std::streambuf

[Code].....

View 6 Replies View Related

C++ :: SDL Unable To Open Application

Sep 7, 2013

I have this problem, then solve it by using the other kind of SDL.dll(eg. 32-bit instead of 64-bit). However, I get the error

The application was unable to start correctly (0xc00000be). Click OK to close the application.

no matter what SDL.dll I use. So far, the only solution does not work for me,

View 4 Replies View Related

C++ :: Developing Application Without Exceptions

Feb 27, 2015

Is it possible to develop any application without exceptions? I don't want to try and catch exceptions and remove it.but I want to write codes which should never create exceptions is it possible?

View 3 Replies View Related

C++ :: Application Default Parameters?

Mar 16, 2013

I have developed an application in C++ that creates some text files in a directory chosen by the user.

How can I ask the user set a Default Directory Path (and some other default parameters) so that she doesn't have to enter the same data in the GUI everytime the application is run.

The application has been developed using Qt Creator.

View 3 Replies View Related

C/C++ :: How To Determine If Application Is Already Running On Mac OSX

Dec 18, 2014

I have a service A, and an application B. Service A needs to launch application B only if it's not running currently. This can be easily done in Windows by calling GetExitCodeProcess function. I cannot find an equivalent method for doing so in Linux/Mac.

So my current code says:

system("open /Users/adsmaster/client/client &"); // to launch the application from the service in a new shell

I read that on a Linux-line machine you can use $ cal to get the exit value of the recently run process but I am not sure how can get the exit value of a particular process?

View 1 Replies View Related

C/C++ :: Opening Application From Another Linux Mac

Dec 15, 2014

I want to open an application A from another application B. By opening it, I don't want to open it within B. I found many ways to call an application from within another. However, what I want to do is open the other one(A) simultaneously. How can I achieve this? fork() and exec() seem to open A within B. I am developing a code for Linux and Mac.

View 7 Replies View Related

C/C++ :: How To Get Active Application Title Through API

May 2, 2012

Actually i am using one timer, in that timer i am trying to displaying one dialog box nane as ABC, for if condition is success, there in the same condition i need to put one more query like for the perticular application is active then only display this dialog box ABC, i need which API is using for getting active application in c++.

View 2 Replies View Related

Visual C++ :: Run MFC Application From Console?

Feb 7, 2013

I have a question about to run an MFC dialog based C++ application from console: if I run my application from console, I see the application start and the console immediately back to prompt. I need that console wait the application exit before show me the prompt again. I tried on Visual Studio 6, 2005 and 2010 but the behavior is the same.

View 3 Replies View Related

Visual C++ :: Two ChlidFrames In One MDI Application?

Jun 23, 2014

I want to achieve such an efect like - one view which takes all MDI area and some views which arelike non modal dialogs

Two Child frames will be correct? one for "big" view which will be always visible and second for a "smal" views

View 2 Replies View Related

C++ :: Best Std Container Class For Application?

Jan 16, 2012

I have a class called CTestObject and it has one variable int id. I want to add instances of this to an std container and be able to:

1. quickly determine if the value of "int id" exists in the container and update the object

or

2. add a new object to the container

Which std container is the best for this application? What method should I use to search the container for the object id?

View 14 Replies View Related

C :: UDP Application Simulate Packet Loss

Aug 12, 2014

have udp server-client application written in C. On the client side packet loss is detected using recvfrom function and sequence numbers of packets. How can I now simulate dropped packet's on the client side, for example if server is sending 1000 packet I want to drop 20% of them? I want to do this in the code, not for example using ip tables or WANEM or something like that. And one more thing, I have few clients and I want that they can dropped different packets, not the same one.

Code:
while(1){
nbytes = recvfrom(socket, buffer, MAX_SIZE, 0, (struct sockaddr *) &srv_addr, &addrlen);
if (nbytes != -1) {
// packet is received

}else{
//packet is not received
}
}

View 2 Replies View Related

C :: Best Process For Cross Compiling Application

Oct 26, 2013

I'm creating a small command line game in C. I have never done anything cross platforms, but this is small enough (so far) that it might not be too bad.

When I am done, I'm not sure how it will be distributed: Either I will just send people the C files and say "compile on your system with these options", or I will just have executables for various systems. Probably Windows 7/8, Ubuntu, CentOS, and whatever I can find to test on.

I right now I'm testing/developing on Windows 7 using MinGW. So my questions are: while I'm developing, how should I be compiling/testing it?

View 4 Replies View Related

C :: Make Console Application Run As Service

Sep 20, 2013

I'm trying to make this run as a service so that kbhit can be interacted with even when the console is out of focus. How would I do this?

View 3 Replies View Related

C# :: Getting Text Contained In External Application

May 8, 2012

i'm iterating through the system processes an when i find a process that belongs to a text oriented application, i want to read that text inside the external app. For example, when i get the process to an instance of notepad, i want to get the text contained inside notepad. i've tried to do it using Process.MainWindowHandle pointer, but with no success. How to do it? (This is for an "nanny" app i'm writing, which need access to text in external applications so that i can detect any unappropriated words)

View 3 Replies View Related







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