C++ :: Execution Of Certain Commands - Setting Device Time

Sep 10, 2013

I got a assignment in which i have to write codes for execution of certain commands.

One of the command is set_time. if user enters set_time 12:12:12

The time should get reset to 12:12:12 no matter what it is now.

View 7 Replies


ADVERTISEMENT

C/C++ :: Round Robin Execution With Gantt Chart - Arrival Time And Burst Time

Mar 10, 2015

This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??

#include<stdio.h>
int main(){
int i,j=0,n,time,remain,flag=0,ts;
int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];
int ganttP[50],ganttStartTime[50];
printf("Enter no of Processes : ");
scanf("%d",&n);
remain=n;

[Code] ....

View 2 Replies View Related

C# :: Open And Read CSV File One Line At A Time Using SQL Commands - OleDb Exception

Apr 7, 2010

The objective: Open and read a CSV file one line at a time using SQL commands.

The problem: I am getting an error that I have a feeling may not point to the "real" problem.

Where I may have syntax or other errors in code.

stInputConn = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=V:\IT\RE\Exports\;Extended Properties="text;HDR=YES;Format=Delimited(,)"";
OleDbConnection cn = new OleDbConnection(stInputConn);
stInputFileName = ConfigurationManager.AppSettings.Get("InputFile");
// the input file name is CSV_DataExport.CSV

[Code] .....

The last line (ExecuteReader) is where I get the OleDb Exception.

View 9 Replies View Related

C :: Execution Stopped Every Time Try To Add Data From Scanf

Nov 12, 2013

this is a syntax i've been trying to run. apparently it stopped as i entered the first value. this is the value i am trying to key in

Initial House Cost 67,000 62,000 75,000
Annual Fuel Cost 2,300 2,500 1,850
Tax Rate 0.025 0.025 0.020

my syntax are as below

Code:

#include <stdio.h>
#include <conio.h>
int main(void) {
float houseInt1 , houseInt2 , houseInt3 ;
float fuelAnnual1 , fuelAnnual2 , fuelAnnual3;
float taxRate1 , taxRate2 ,taxRate3;
float total1 , total2 , total3;

[code]....

View 9 Replies View Related

C Sharp :: Counting Execution Time Of A Task?

Nov 9, 2013

I am checking out this simple piece of code:

private void button1_Click(object sender, EventArgs e)  {
            Stopwatch sw = Stopwatch.StartNew();  
            Task Task1 = Task.Factory.StartNew(() =>  {
                    Console.WriteLine("Task1 started in : "+ " "+sw.ElapsedMilliseconds);
                    Thread.Sleep(4000);
                    Console.WriteLine("Task1 finished in : " + " " + sw.ElapsedMilliseconds);
                }
                );
        }

and the results are :

Task1 started in : 2 in milliseconds
Task1 finished in : 4015 in milliseconds.

The problem is, that if i count the time with an external device, just like the timer of my watch or my cellphone s,the total time is 4,8 or 4,9 seconds, which i wouldn t expect that to happen.

The first thing i ve thought, is that it takes the ThreadPool about 800msec or 1 sec to create the thread so as to execute this task, but even if it is so, shouldn t the stopwatch count the time precisely?So , why is there a deviation between an external timer and the stopwatch ?

View 1 Replies View Related

C++ :: Measuring Execution Time Of Static And Dynamic Binding

Jan 11, 2013

consider the code bellow

#include<iostream>
#include<ctime>
#include<boost/progress.hpp>
using namespace std;
class parent {
public:
virtual void dynamic_display(){

[Code] ....

I am getting the following as output

Calculating....Static Function is called1times
The number of processor clicks is0time is0
Calculating....Dynamic function is called1times
The number of processor clicks is0time is0
Static Function is called2times
Dynamic function is called2times
Static Function is called3times
Dynamic function is called3times

I am actually trying to calculate the time to execute a statically binding method and a dynamically binded one.consider only the first four lines in my output. Why am i not getting the actual result.

View 3 Replies View Related

C/C++ :: Sequential Matrix Multiplication - Error In Execution Time

Apr 30, 2014

I wrote program for Sequential matrix multiplication .But after execution for any input value( ex. 100,150,400) it shows the execution time is 0.000 msec.

#include <stdio.h>
#include <math.h>
#include <sys/time.h>
void print_results(char *prompt, int N, float *a);
int main(int argc, char *argv[])

[Code] ......

View 2 Replies View Related

Visual C++ :: Obtaining Actual Effective Execution Time Per Thread With Hyperthreading

Jun 13, 2013

I'm looking for a function like GetThreadTimes, but one that gives correct results in a hyperthreading CPU.

For instance, if you start 2 threads on a CPU with 1 physical core and 2 logical cores, GetThreadTimes will say that both these threads use 100% CPU.

However, in reality they only use 50% each. Is there a function that returns correct results, or is there another workaround?

View 8 Replies View Related

Visual C++ :: Read Table And Get All PNAME Into Combobox - Reduce Query Execution Time

Nov 14, 2014

My table:

Code:
Database name: test & Table name : Profilemaster
+-----+--------+
| PID | PNAME |
+-----+--------+
| 1 | APPLE1 |
| 2 | APPLE2 |
| 3 | APPLE3 |
| 4 | APPLE4 |
| 5 | APPLE5 |
| 6 | APPLE6 |
| 7 | APPLE7 |
| 8 | APPLE8 |
| 9 | APPLE9 |
| 10| APPLE10 |
+-----+--------+

I like to read the table and get the all PNAME into the combo box.

Using the below code i can read the table, but while loop takes 2 seconds to read 10 records in the Profilemaster table.
How can i reduce the reading time?

My Code is
void MainScreen::OnreadProfileName() {
CDatabase database;
CString SqlString;
CString sDsn;
CString pname;

sDsn.Format("Driver={MySQL ODBC 5.2 ANSI Driver};Server=localhost;Database=test;User=root;Password=client;Option=4;");

[Code] ....

Is any other way to reduce the query execution time?

View 6 Replies View Related

C++ :: Setting Time Limit For A Level In 2D Game

Jan 2, 2014

So I am have made this 2D ball game. But I want to set a time limit for each level. I want player to play that level for maximum 3 minutes. After 3 minutes the game level should end. I have used allegro 5.0.10 with c++ . How to achieve it?

View 2 Replies View Related

C++ :: Can't Use System Commands

Nov 7, 2013

So, as far as I can tell, this code should run a system command from the C++ program:

system("ping 192.168.1.2 /t /l 32768");

However, I just keep getting a "system Was not declared in this scope" error message. Is there something wrong with this?

View 1 Replies View Related

Visual C++ :: Send Commands Or Variables

Jul 19, 2013

I'm trying to create an executable with C or C++ that send a command with the function system, but it waits for a command or key.

Example :

I send this:

C:
unas /noprofile user:administrator notepad.exe

But it waits for password.

Please type the password :

So my question is how can I make to send the password or that my program detect that prompt.

View 1 Replies View Related

C++ :: Look-up Mounting Point Of USB Device

Apr 15, 2013

I'm developing a short c++ program to scan all devices connected to the system through the USB connections.

I have used libusb to scan them and it really works but this library does not provide me with the mounting point, so I get a list of devices including manufacturer, serial number, etc but not the mounting point.

I have also used libudev library but it seems to happen something similar...

I need to get the mounting point for all USB devices connected to the board, you know: /dev/ttyUSB0 ....

View 1 Replies View Related

C/C++ :: Use Analog Device Through USB Interface

Sep 25, 2014

I am supposed to write a C program to send through USB interface to the analog device AD9914. Now I am doing the USB interface part where my computer has to detect the AD when it is plugged in and send the signals to it. I have to write the program to detect the device when it is plugged in. What kind of functions can I use? I know that the registry stores the device when it is plugged in. What functions are available to read?

View 2 Replies View Related

C/C++ :: Retrieve Data From USB Device

Jun 16, 2014

I am looking to retrieve data from a USB device, this device is a fingerprint scanner. Because I bought it online and wasn't reading carefully enough, drivers and other installation programs weren't included. Send it back? Nah . . .

I want to see if it is possible to retrieve data from this device. To be honest, I don't even know if it's possible, but I would love to give it a whack.

I looked into making INF files and things Microsoft has put out, but I honestly don't know where to start simply because I have absolutely no experience doing this. I have a program set up to organize the data and such, I just need to find a way to actually get it.

What should I research and look into? Are drivers necessary?

Here is a little more information :-)

I want to save data from a fingerprint scanner.I bought a fingerprint scanner, but nothing came with it (drivers, software, etc.). I decided to not return it and see what fun I could have.

I have no code written up yet (mainly because I don't know where to start). But I looked into the device a little...Microsoft recognizes it as a "Fingerprint Scanner" but is still considered unrecognized.I have the USB identifier (at work right now, don't have it on hand)...

Is it even possible to communicate with the device without the initial drivers.Do I really need drivers for the device, or can I communicate with it as it is now.If I do need drivers, where should I start?What should I look into to get communicating with the device?

View 6 Replies View Related

C Sharp :: How To Get A Device Name For A Given Ip Address

Aug 13, 2013

I need to get the network device name for the given ip address..

I tried with dns.getHostByaddress but it didn't worked..

View 1 Replies View Related

C++ :: How To Skip A Block Of Commands When User Interrupts

Nov 3, 2014

I am working on a program that does something like this,

Void main() {
cout<<"H";timedelay(1);
cout<<"E";timedelay(1);
cout<<"L";timedelay(1);
cout<<"L";timedelay(1);
cout<<"O";timedelay(1); //timedelay(int a) is a function which gives a delay of 'a' seconds.
{
....
}
}

This code is just for fancy and I would like to squish in some statements which would give the user an option to skip it (by entering any keyboard key),and resume with the rest of the program.

View 10 Replies View Related

C/C++ :: How To Use Windows Command-line Commands In Code

Sep 18, 2012

In Windows, if you open a command prompt, there are a bunch of keywords like, 'chdir', 'copy', ...

What I'm trying to figure out is how to use that COPY command in c++ code. I want to use the COPY command with the options (/a, /b, ...).

View 3 Replies View Related

C++ :: Modelling Device In Embedded System?

Oct 13, 2013

What I want to do is abstract and model a device (more specifically in this case, an IMU) in an embedded system.

Now, there are a couple of gotchas:

- It is basically a framework, which means that it should work with any device, any platform and any bus.

- It is an embedded system, so power consumption and memory consumption must be reduced. It is not a PC.

- It cannot be too complex, because I fear that will just make people scrap it and rewrite it from scratch :P

- It should aim for as little code as possible to write the whole model, of course. Adding 100 lines of code for each register would be a bummer.

That said, I must also model the current system, which means that the current platform, the current bus (which is I2C) and the specific IMU model (I have a datasheet).
So the model I am thinking of currently is this:

First, I have a platform. It will know what bus a device is connected on and contains the buses (or specifically, the instances of the buses). It consists of a specific class for each platform and a base. Here are the two I have now:

Code:
namespace Sensors
{
template<typename Platform_t> class GPS;
}
namespace Platforms
{
class RaspberryPi: public PlatformBase

[Code]....

Currently I am making the assumption that all platforms will have an I2c bus and UART bus, but I'm not sure about that. We have only one platform ATM, though, so for now this holds. I'm guessing I might have to move it to the specific platforms later and get rid of PlatformBase.GetI2CBus is a problematic one related to registers, but I'll get back to that.

UART is simple to model since it's just a block read and write, so:

Code:
namespace Buses
{
class UART
{
public:
UART(const std::string& UARTPath): m_Open(false), m_PathToUART(UARTPath) {}

[Code]....

I'm probably going to handle all errors through exceptions. So if I can't open the UART bus, I'll throw an exception.

The I2C bus is a problem. I have a model which deals with it on a register-based level, but ideally I'd like to be able to model and use the devices on the I2C bus on a flag-based level (ie, I have names for each individual flag in the registers which I can read or write to directly instead of writing a hexadecimal value directly to each register).

Here is code:

Code:
namespace Buses {
template<unsigned int Id>
class I2CDevice {
public:
I2CDevice(I2C& Bus): m_Bus(Bus) {}
template<typename T>

[Code]....

So I2CDevice does some checks to see that the data to write to a register is either 8 or 16 bits. It does not check that the size to write matches the register's size, but another class does not.

The idea is also that it checks which device is currently active on the bus, and if it's not the current I2CDevice, then it simply selects that before attempting to read or write (the Open call).

This is not meant for multi-threaded environments. Yet, anyway.

The Impl2::Read/Write just dispatches the call so it calls the correct function for writing and reading the correct size, depending on the size of the data.

This is all well and good, but I2C works with registers, so of course I want a class to model a register which I can read and write to directly. It must tie into the bus class since the bus class is the one that abstracts reads and writes on the bus.

The register class looks like:

Code:
template<unsigned int Bits, unsigned int RegisterId, typename Bus_t>
class Register {
public:
typedef typename Impl::RegisterBase<Bits>::Storage_t Storage_t;
static_assert(!std::is_same<Bus_t, Buses::UART>::value, "Cannot read and write registers on the UART bus.");
static_assert(Bits == 8 || Bits == 16 || Bits == 32 || Bits == 64, "Number of bits must be 8, 16, 32 or 64.");
auto Write(Storage_t Data) -> void

[Code]....

I think this explains itself, except for the Regs struct, which is an experiment by me to enable myself to access registers via Regs.Config, etc.

What is missing is the ability to access and read/write the individual bits inside the registers. I am thinking a two-way access, where you can write to individual bits, but must call .Write() to commit the write to the register for efficiency.

I haven't actually written this. I don't know a good way ATM. I don't want to add a lot of variables and a write function because that would use 1 byte for every bit which is unacceptable.

I don't want to add a lot of code to make it work, either. A good get/set class would be nice, but I can't see that working. The register must store all state and any subsequent classes must not store any state or overhead will increase.

Finally, yes, I know a lot is incomplete and untested. It probably won't even compile. But that is for later. First is finishing the model.

It would be nice if things such as the platform and buses could be made static because there will only be one instance at any time, and that would save overhead if I don't have to store objects or references to them, but I haven't figured out how to achieve this.

View 13 Replies View Related

C :: Netstat And PS Commands For Client / Server Socket Programming

Mar 3, 2013

I made client server program with fork ,without using signal handler because I want to see the status zombie for parent server, but when i execute "ps" command i didn't see anything for server or client pid or ppid ,i wonder about how to show the server and client process coz when i execute commad "ps" i saw only ps and bash processes???

View 1 Replies View Related

C :: Program That Displays Menu Of Commands For User To Choose From

Aug 1, 2013

I've read that we can write a program that displays a menu of commands for the user to choose from.We can write some functions that implement these commands, then store pointers to the functions in the array :

Code:
void ( *file_cmd[])(void) = { new_cmd , open_cmd }; // 2 cmd's for simplicity

We can get a similar effect with a switch statement but using an array of function pointers gives us more flexibility since the elements of the array can be changed as the programm is running.

I decided to write an example about this in order to understand better the context, I am facing some problems though :

Code:
#include<stdio.h>
#include<stdlib.h>
typedef void (*p_foo) (int);
void foo(int x);
void foo2(int y);

[Code] .....

The problems are :

Code:
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:25: error: too few arguments to function "*(arr + (long unsigned int)((long unsigned int)i * 8ul))"

View 14 Replies View Related

C++ :: Using Clear Device And Sleep Functions In Graphics

Dec 14, 2014

I have a college project which is a car racing game using C++ and the old-school graphics library BGI. After I draw the map and placed the objects(Car,obstacles,road's borders etc..)I added Sleep(); function to the function named Obstacles(); but the problem is, I can't move the car with the right&left arrows.a

Another problem,If I added a cleardevice(); command all objects disappears only the obstacles function keeps working. the Code is here:

char c;
do{
c = (char)getch();
if (c == KEY_LEFT) {
x = x - 10, x1 = x1 - 10;
} if (c == KEY_RIGHT) {
x = x + 10, x1 = x1 + 10;

[code].....

note: this is not the whole code, it's only a small portion of it, not a debugging question only need a hint how to fix it.

View 3 Replies View Related

Visual C++ :: Reading NFC Device - Callback Function?

Jan 7, 2015

Is it possible to read NFC card reader in VC++/MFC. Is it possible to develop a callback function that will read the NFC device, and see once the card is inserted, it takes that value from the card and store it in a DB?

View 3 Replies View Related

C :: Gzip System Linux - Program To Unite 2 Commands Into 1 Command

Sep 15, 2013

I'm writing a program to turn the two commands "gunzip file.tar.gz" then "tar -xvf file.tar" into "x file.tar.gz", but I've ran into a problem I can't find a solution to, here are the outputs I get depending on if I use a gunzip -f flag in my system() call or not:

if I use: (void)system("gunzip ", store );
> x file.tar.gz
gzip: compressed data not read from a terminal. Use -f to force decompression.
type: gzip -h
store 1: file.tar.gz
tar: option requires an argument -- 'f'

[code]....

I don't know if the problem is something to do with my code or something to do with gunzip and if it is to do with gunzip if I can even solve it with my code? I've tried for a while to find more info and read the gunzip man file, ran "gunzip file.tar.gz" outside of my program and found that it works normally producing file.tar so I suspect the problem is related to system()?

View 3 Replies View Related

C++ :: Recursive Function - Creating Vector Of Every Unique Combination Of Commands

Mar 24, 2013

I'm trying to write a recursive function that takes in a vector of strings that contains

"1 forward", "2 forward", "rotate left", "2 backwards" ... etc

how can I write recursive function that creates a vector of every unique combination of commands?

View 8 Replies View Related

C/C++ :: How To Make Food Ordering Program Utilizing Voice Commands

Apr 19, 2014

I was interested in making a food ordering program utilizing voice commands. I hope to build a GUI with items listed on one side, and with voice commands picking up on key words that will add the food to the right of what you chose.

View 4 Replies View Related







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