C :: How To Implement A Generic Command
Jun 11, 2013
I have to make a prgrama using the C programming language that is able to read several lines of commands entered by the user and interpret it as a command to run.
I have to implement the following command:
a) Command generic - program should be able to read any one command and execute the same command on the operating system through primitives for implementing generic processes (eg "ls-l/etc").
View 1 Replies
ADVERTISEMENT
Feb 15, 2013
I am facing a problem in C++,I want to execute a command in Command prompt from a specific path.I am able o select a path and execute cmd.exe using the function ShellExecute but the problem is after selecting the path I am not able to execute the command, the command is appearing on another command prompt.
View 4 Replies
View Related
Jan 26, 2013
Write a generic class Set that models the set.
Class Set should contain: appropriate constructors, destructor,
overloaded operators = (assignment), += (union), * = (cross-section),
the methods insert, remove, and print.
Write a class Combination which models the combination of numbers and includes object-Member: numbers
(use Set <int>), appropriate constructors, destructor, methods add, delete, print and merge (connects two combination; use overloaded operators of generic class Set).
Implement all methods.
Write a short test program.
View 5 Replies
View Related
Dec 6, 2013
I'm building a pretty basic calculator program that calculates the area of generic shapes (triangles, rectangles, and squares); for some reason though, my program is having troubles as soon as it hits the if/else code in the int main section. When I enter triangle, rectangle, or square, it just spits back out the "That's not one of the options. Please re-enter and try again." error line I created. When I isolate and run just the stuff inside the if/else statements it works great, but why it won't just understand my if (shape == triangle).... .
Code:
#include <iostream>
using namespace std;
class figure {
protected:
double x, y;
[Code] ....
View 2 Replies
View Related
Aug 20, 2014
Let's first take the following class prototype:
#include <ctime>
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
class Debugger;
class Debugger {
[Code] ....
My question is regarding the GetCurrentDebugLevel function above. Ideally I would like to use just one function to get the current debug level of the class, the std::string form would be used to save the "debugging level" in a settings file and the enumerated version would for evaluation purposes throughout the program.
My question is if implementing function prototypes by return value the best way to go or should I do something else?
View 4 Replies
View Related
Mar 9, 2013
I'm passing an array into this function and it's taking the item at index 0 and replacing the rest of the array with it.
Code:
void generic_sort (void *arg, size_t num, size_t size, int (*cmpfnc) (const void *, const void *)) {
for (int i = 1; i < (int)num; ++i) {
int j = i;
char *tmp_address = malloc (sizeof (arg));
tmp_address = (char *)arg + j * size;
[Code] ....
View 13 Replies
View Related
Apr 1, 2013
I have defined my own class, Queue, which inherits from my own class, LinkedList. I have been using templates to allow Queues to be of int, string, etc types.
But now I want to be able to store objects in my Queue type. And so the problem I have is that in my LinkedList class, I have two instances where I initialize an instance of my generic type T to 0.
For instance, the removeFirst() method starts like this:
template <typename T>
T LinkedList<T>::removeFirst() {
T a = 0;
And so the compiler complains that it can't convert from int to [in this case] Command&.
What to do?
View 2 Replies
View Related
Feb 4, 2014
I'm trying to implement my own Stack class, for a generic data type. Here is what I have so far, but I'm having problems compiling the code:
Stack.h:
#ifndef STACK_H
#define STACK_H
#include <vector>
template< typename T >
class Stack {
[Code] .....
View 5 Replies
View Related
Aug 24, 2013
I am having problems copying this data structure (memory leaks).
Code:
typedef struct List {
int x;
void *ptr;
struct List *next;
} List;
The problem is allocating memory for void *ptr.
View 2 Replies
View Related
Oct 3, 2013
I was writing generic class Array (based on counting access to elements)and i got compiling error I cannot even understand (in vs2012).
Code: [URL] ....
Error: [URL] ....
View 8 Replies
View Related
Feb 23, 2014
I'm trying to write a function for receiving messages, so my classes can communicate with each other. The only issue I get is a compile error asking me to define the base parameter as one of the derived instances. I tried using a void* to fill the need, but then I lose the initial type, which I need to check for. How might I go about writing a generic object for this?
Here's my code:
template<class Object>
class State
{
public:
[Code].....
Should I just have all of the objects inherit in the order of Object >> GenericObject >> DerivedObject?
View 10 Replies
View Related
May 19, 2014
I am trying to write a generic linked list in c, but for some reason i keep getting errors saying "incompatible pointer type. This is the code and erros:
#ifndef SLIST_H
#define SLIST_H
#include <stdlib.h>
typedef struct {
void *data;
slist_elem *next;
[code]....
View 2 Replies
View Related
Apr 26, 2014
I have a situation where I am accessing an ASP.NET Generic Handler to load data using JQuery. But since data loaded from Javascript is not visible to the search engine crawlers, I decided to load data from C# and then cache it for JQuery. My handler contains a lot of logic that I don't want to apply again on code behind. Here is my Handler code:
public void ProcessRequest(HttpContext context) {
JavascriptSerializer jsonSerializer = new JavascriptSerializer();
string jsonString = string.Empty;
context.Request.InputStream.Position = 0;
using (var inputStream = new System.IO.StreamReader(context.Request.InputStream))
[Code] ....
I can call the function : getUserControlMarkup() from C# but I will have to apply some URL based conditions while calling it. The contentType.typeOfContent is actually based on URL parameters.
If possible to send JSON data to this handler then how to do that. I am trying to access the handler like this:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Common.host + "Handlers/SideContentLoader.ashx?typeOfContent=1&UCArgs=cdata");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
But its giving NullReferenceException in Handler code at line:
ContentType contentType = jsonSerializer.Deserialize<ContentType>(jsonString);
View 1 Replies
View Related
May 20, 2013
I'm trying to learn how to implement vectorization. Lets say I have this an array like this.
Code: int Array[10] = { 3,4,5,3,4,5,6,7,8,9};
If I traverse through the array and preform some simple calculation like adding numbers, how would I go about vectorizing this feat? For example if I want to add numbers, .
An example, add element at index 5,6,7 to element with index 1.
Code:
0 1 2 3 4 5 6 7 8 9 --- index
3,4,5,2,8,2,3,5,1,2 --- ints
View 6 Replies
View Related
Feb 23, 2015
I am trying to implement setjmp for functions.
Code:
#include <setjmp.h>
#include <stdio.h>
jmp_buf arr[3];
void DISP(int x , int i)
[Code]....
Could I possibly use malloc to allocate memory for the stack too?
View 1 Replies
View Related
Feb 10, 2013
Code:
char str[40][40];
int number = 7;
for (int i=0;i<number;i++){
printf("enter %d th string::",i+1);
scanf("%s",str[i]);
}
Above, I have a little snippet of a code that I'm trying to figure out. I don't really understand how to implement 2d arrays in C that well. But, I mostly want to know is how and where the strings are being stored, especially with the code below.
Code:
for (int i=0;i<number;i++){
printf("enter %d th string::",i+1);
scanf("%s",str[i]);
}
I know that it's asking the user to enter strings, which will be stored into the 2d array. I just don't understand how it's being stored. Will it be placed in the 1st column or 2nd row or something?
View 1 Replies
View Related
Mar 25, 2013
I'm trying to implement the flocking algorithm in C++. I've tried to implement it myself by making all the particles 'home-in' on the player. When 2 particles then collide within their larger bounding boxes they home-in to each other. And when the 2 particles are actually touching they repel each other until they are outside of their bounding boxes and find another particle to home-into.when I run my application the particles all home into the player and come to a stand still along the Y-axis above the player.
All the particles in question are stored in a Vector, with a pos and velocity.
for(int i = 0; i < swarm.size(); i++) {
for (int j = 0; j < swarm.size(); j++) {
if (swarm.at(i)->getParticleModel()->getPosition().x < gameObjects.front()->getParticleModel()->getPosition().x) {
if (swarm.at(i)->getParticleModel()->getTouching() == false)
[code]....
View 5 Replies
View Related
Nov 2, 2014
I implement copy constructor for priority queue like this, is it right?
PRIORITY_QUEUE<T>::PRIORITY_QUEUE(const PRIORITY_QUEUE &aQueue)
{
this->maxSize = aQueue.maxSize;
this->items = new T [maxSize + 1];
this->rear = aQueue.rear;
for (int i = 0; i < aQueue.rear; i++)
[code]....
By the way, how to implement "insert" and "heapify" and in insert, when we insert an element we also heapify it?
View 2 Replies
View Related
Apr 15, 2014
Ok so i am coding in WPF i was coding just fine and im trying to implement a browserDialog
Here is the class
The issue i am having is in the DialogResult.Cancel This is the issue i receive 'System.Nullable<bool>' does not contain a definition for 'Cancel' and no extension method 'Cancel' accepting a first argument of type 'System.Nullable<bool>' could be found (are you missing a using directive or an assembly reference.
private void ArmaPathSelect_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
if (folderBrowserDialog.ShowDialog() == DialogResult.Cancel)
return;
this.Path_Arma3.Text = folderBrowserDialog.SelectedPath;
}
View 1 Replies
View Related
Dec 12, 2013
I do this because I want to transform the .x format into xml... The "frame" data structure can contain other frames, and a name for the frame and a transformation. For example:
Code:
struct frame {
std::string name;
Matrix transform;
std::vector<struct frame> child;
std::vector<struct frame> sibling;
[Code] ....
I know the above won't compile. But am I on the right track to implement data structures this way using linked lists? about directx, I'd like to ask is the .x format implemented with a tree structure rather than linked lists.
View 1 Replies
View Related
Jan 5, 2014
Not inheriting properly and provide the corrected code if possible
Code:
#include <iostream>
using namespace std;
class Node {
protected:
int Data;
[Code] ....
View 4 Replies
View Related
Feb 23, 2013
I have a struct and I want to implement in with pointers and functions.
What is the corect syntax? For example:
Code:
typedef struct XYZ
{
int x;
int y;
int z;
}XYZ_t;
int func( using the XYZ_t struct)
[Code] .....
View 5 Replies
View Related
Jul 24, 2013
I'm trying to implement the Merge-Sort algorithm. I only had the pseudocode for it and have some problems coding this into C.
I have only covered pointers recently and I tried using them, which did not work. I started with the code for the merge algorithm and only used a 10 element array, which was already divided into two sorted subarrays:
Code:
#include <stdio.h>#include <stdlib.h>
int main() {
int a[5]={1,5,6,10,13}, b[5]={4,8,9,10,14},c[10], *i,*j,k;
[Code].....
This is the result that I get:
Code: 1 4 5 6 8 9 10 10 13 0
So I think the problem occurs because in the second to last loop i is incremented again, but the end of the array is already reached, and the compiler has no element a[6] to compare with *j in the last run of the loop. Is there generally a better way to implement Merge?
View 10 Replies
View Related
Aug 11, 2014
I am starting to use contiki and learn c programming for my summer internship. I have to calculate the mean of the ongoing process of refrigerator power. I made the code like this
Code:
#include <stdlib.h>
#include <stdio.h>
#include <homadeus/processes/fridge_process.h>
#include <homadeus/devices/78M6610.h>
#include <homadeus/utils/utils.h>
float global_variable;
int current_state = 0; //down =0, up =1
[Code]....
How it gets the value of power is handled already. Every one second, it will display the power consumed (get_instant_power()). I don't know how to start and end the sample numbre. If I start by 1 then how should it be until? Also, is it possible if I store the power in array to accumulate?
View 1 Replies
View Related
Apr 6, 2014
I'm attempting to write the maximal clique algorithm for use with an adjacency matrix.I'm following a video which explains how to code and implement the algorithm using python. I want to write it for c++. URL....I'm currently trying to code the powerset function at 2 minutes into the video. I'm not sure if I should be using arrays or not.
So far I have coded the below but I dont know how to return an empty array inside an empty array (when the elts list is of size 0). I wrote an isEmpty function for the array since I cant use len(elts) like in python.
bool empty = true;
bool isEmpty(int elts[]) {
for (int z=0;z<10;z++) {
if (elts[z] != 0) {
cout << elts[z] << endl;
empty = false;
[code]....
The code should use either an array/list/vector that we call 'elts' (short for elements). Then firstly, it should add the empty list [], then the rest of the power set (all shown in the video).So for example, in the case that elts = [1,2,3,4], my code should return:[ [],[4],[3],[4,3],[2],[4,2],[3,2],[4,3,2],[1],[4,1],[3,1],[4,3,1],[2,1],[4,2,1],[3,2,1],[4,3,2,1] ]
View 2 Replies
View Related
Aug 22, 2013
I have problems when implementing the IDIV Instruction in gcc assembler, the program has compiled ok, but when executing function that imparts the asm codes which contained the IDIV instruction the error box immediately appeared announcing that it should terminates the program quickly.
The following is the complete listing of the program that I just been working on it:
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
signed long divider(signed long num, signed long divisor);
int main(int argc, char* argv[]) {
signed long dn0,dn1,dn2;
[code]....
I compiled it with DevCpp 4.9.9.2, and I had tried on CodeBlocks, in CodeBlocks I made used the int64_t type but still it could not works more..
View 6 Replies
View Related