C++ :: Maintain Variable Between Multiple Process

Mar 9, 2013

In the existing code,fork has call parallel to create process.my job is to store all the process id into vector so that we can verify the status of the jobs. I was able to save all the jobs but as the callback happen so I have lost my all value which was store into vector.

How can i maintain variable between multiple process.

View 1 Replies


ADVERTISEMENT

C/C++ :: TCP Server / Multiple Client With Select Process And Forking

Sep 12, 2014

I have created a Server that can handle multiple users with the select function. The server seems to be operating just fine on every new request of a client even on the case of termination connection. The problem appears on the client side. I am applying forking process to be able to hear and write at the same time while the user is typing a message to the rest of the clients. By doing so I discovered that when the client is initialized it send a blank message to the server. The server then send this blank message to all the clients. I have discovered a "trick" not to display the message on the client side but I really would like to know if there is an alternative solution instead of my solution. I mean why it dose not wait for the client to first start typing a message before to send it.

The communication that will apply on each new connection is:

Client Server
Connect() −− >
< −− Hello version
NICK nick −− >
< −− OK/ERROR text
MSG text −− >
< −− MSG nick text/ERROR text

Sample of the Server.c code:

#include <stdio.h> /* stderr, stdout */
#include <errno.h> /* errno.h - system error numbers */
#include <stdlib.h> /* memory allocation, process control etc. */

[code].....

View 6 Replies View Related

Visual C++ :: Application That Process Multiple Files Through Command Prompt Call

Dec 22, 2012

I am making an application that processes multiple files (typically > 500) through a command prompt call. The way I start the command prompt app is by looping using a call to CreateProcess for each file that is to be processed. It works fine, except that I somehow loose 'connection' to my app so that

1: Windows says that the app. is 'Not Responding'
2: The Cprogress bar in my app is not updated before all files have been processed, even though there is a CreateProcess call and a Cprogress.StepIt() from the app for each file that needs processing.

I somehow suspect that the CPU gets swamped... I do not want that Windows starts to say that my app is 'not responding' and I want my Cprogress dialog bar to update according to the number of files that are progressed through.

I wonder if multithreading is the OK way to go instead of just kicking of series of CreateProcess calls? Maybe my CreateProcess is not ending correctly? It seems as if my app is 'not regaining control' before very late. The app never crashes though.

My CreateProcess code is listed below, maybe there can be a problem with it, or maybe I should do things in a different way? My app basicaly works as it never crashes, but with above mentioned problems it is NOT a pro solution...

void CMultiFilerDlg::ProcessFile(CString pdfFile) {
int i=0;
DWORD ProcID;
// Open file in text mode:
STARTUPINFO si;
PROCESS_INFORMATION pi;
char cmdArgs[2052];

[Code] .....

View 6 Replies View Related

C :: Variable Access Across Multiple Files

Sep 7, 2013

I was trying out programs based on extern and as i understand, this is useful when accessing variables across multiple files having only one definition. But i tried a simple program as below without "extern" and thing seem to work when i expected it would fail during linking process

Code:
file5.c
1 #include <stdio.h>
2 #include "var.h"
3
4 int main() {
5
6 printf("
File5.c a = %d", a);

[Code] .....

As i have included "var.h" in all header files without extern, "int a" would be included in both the .c file and during linking, compiler should have thrown a warning or error message but it compiles file without any issue. Shouldn't var.h have the following "extern int a"?

View 8 Replies View Related

C/C++ :: Multiple Malloc Calls On One Variable?

Feb 13, 2013

I'd like to know what happens if I use multiple calls to malloc() on one pointer (without free) in a single function. Here is the example:

void *data_thread(void *sockfd_ptr) {
  int sockfd = *(int *) sockfd_ptr;
  const int BUFSIZE = 5;
  char recvmessage[BUFSIZE];
  char *headerstr = NULL;
  char *newheaderstr = NULL;

[code]....

what happens with newheaderstr every time malloc() is called. There isn't a realloc() or anything. I didn't think it looked right to keep using malloc() like that.

View 4 Replies View Related

C :: Maintain A List

Apr 11, 2014

I want to maintain a list. which will update at regular interval. so I thought to with linked list. Earlier I have used linked list.

Code:

typedef struct
{
short nwkaddr;
unsigned char macaddress[8];
}device_t;
}

[code]....

This program is giving many errors. I tried lot to fix it. If I fix one then other bug is arising. for that I did't mentioned what bug i got.Main Issue is while (curr->next->list != NULL) this is giving segmentation fault if i add element second time

View 3 Replies View Related

C/C++ :: Assigning Variable From Multiple Choice Answer

Oct 29, 2014

I tried to create a multiple choice list and I want to assign the value of the answer option chosen by the user so I can use it later on in the code. Later on in the code i've asked how many people (p) want a drink and multiplied it by the chosen size to calculate the price c = p * n where c is cost, n is price and p is number o of people At the bottom i tried to assign parameters where depending on what option the user has chosen n will be assigned to the chosen value...

{
printf("SELECT TYPE OF PAINT:"); /*multiple choice of paint */
printf("1. Large ");

[Code]....

View 1 Replies View Related

C++ :: Passing Multiple Variable To Function That Has Stringstream And Text

Dec 24, 2013

I have a quick question about passing multiple variable to a func that has (stringstream & text). Here is the code:

void PrintText(stringstream & txt) {
cout << txt.str() << endl;
}
void main() {

[Code] ....

How to make second one work?

View 11 Replies View Related

C++ :: Program To Maintain Database - Name And Birthday

Oct 16, 2014

Write a program that maintains a database containing data, such as name and birthday, about your friends and relatives. You should be able to enter, remove, modify, or search this data. Initially, you can assume that the names are unique. The program should be able to save the data in a fi le for use later.

Design a class to represent the database and another class to represent the people. Use a binary search tree of people as a data member of the database class. You can enhance this problem by adding an operation that lists everyone who satisfies a given criterion.

For example, you could list people born in a given month. You should also be able to list everyone in the database.

View 3 Replies View Related

C++ :: Trying To Add Template Class To Maintain List

May 12, 2013

I wrote this menu-driven program that maintains a list of restaurants. The program runs fine as it is right now, but my problem is I need to create a new array template class to maintain the list of restaurants, and when a new restaurant is added it must be created dynamically.

I'm having a hard time figuring out what exactly I need to do for this. Templates confuse me allot and I've read all the sections on templates here and in my book, but i'm still lost. The dynamic memory part is throwing me off as well.

main.pp

#include <iostream>
#include <string>
#include <iomanip>
#include "Restaurant.h"

[Code]....

Restaurant.h

#pragma once
#include <iostream>
#include <string>
#include "FTime.h"
using namespace std;

[Code]....

Restaurant.cpp

#include "Restaurant.h"
#include <iostream>
#include <string>
#include <iomanip>
#include <sstream>
using namespace std;

[Code]...

FTime.h

#pragram once
#include <string>
using namespace std;
//class FTime
class FTime {
friend ostream& operator<<(ostream& out, const FTime& obj);

[Code]...

View 3 Replies View Related

C :: Maintain List Of Variables Inside Source File

Apr 24, 2013

I'm about to begin work on an exercise that requires me to maintain a list of the variables inside a c source file. I'm trying to figure out how I'm going to pluck out the variable names from all the other noise. My first thought would be to count any word that isn't a keyword or other type of grammar syntax, such as parenthesis, brackets, semicolons, etc. right?

View 10 Replies View Related

C/C++ :: Maintain Student Academic Records Using Linked List

Sep 16, 2014

Assignment on Linked List : Write a program that maintains student academic records using a linked list. The data structure is to be implemented as an array of structures. The fields of the structure are as follows:

• Student ID - this should be unique

• Last name

• First name

• Middle initial

• Course

• QPA

• Address

The program shall be menu driven. This means that the actions that the user can do with the program is govern by choosing an option. The menu shall look like this:

Student Records

1. Add student Academic Record

2. Edit student first name

3. Delete student record

4. View student record (by last name)

5. View all student records

6. Exit

For the edit and delete, the search value should be the student ID. What's lacking on my codes is for the 3rd option. What should I must do with it? These are my codes

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#define M 10
#define FLUSH while(getchar() != '')

[Code] .....

View 1 Replies View Related

C++ :: Program For Used Car Dealer Company To Maintain Cars Inventory And Details

Aug 25, 2014

You are required to write a program for a Used Car Dealer company. In the system you need to maintain the cars’ inventory and details. Each car in the company contains the following details:

• Car Registration Number
• Car Make or Brand
• Car Model
• Car Colour (eg. Silver, Black , Red)
• Year of manufacturing (The year the car was manufacture)
• Engine Capacity (in cc)
• Transmission (manual or automatic)
• Cost of the car (SGD)

The Car Registration Number is in the format of AAA1234 or AA1234A or A1234A which is accordance to the Malaysia car registration format. The A alphabet is in accordance to the registration number for respective in Singapore. (eg. AEW9829 or W1212Y or MCD1177). Note the A and the 1234 total count in the registration number can be less than 3 like AT9829 or BHY280. The Car Make is for the identifying the manufacturer of the car like Honda, Toyota, Proton..etc. The Car Model is to represent the Manufacturers’ respective model like Honda City, Honda Civic, Honda Accord, Toyota Vios, Toyota Camry … etc.

You are required to create menu and operations for:

1) Create a new Car account
2) Edit existing Car account details
3) Remove a car account from the system
4) Search for cars in the system (based on Car Make, Model, Year of manufacturing or Price)
5) Check total inventory in the system

View 1 Replies View Related

C Sharp :: Maintain Temperature Of Grill And Measure Temperature Using Probe At 12 Points

Jan 16, 2013

I have to write a program for a restaurant and their food has to be cooked on a hot sheet of metal and too cook their burgers properly I must keep a maintain temp of 400 F, for the grill and to measure the temperature using a probe at 12 points, there are 3 elements with 3 points on them

View 2 Replies View Related

C# :: Multiple Desktop Display (Multiple Explorer Windows)

Jul 31, 2014

I want to develop an application which can host multiple views of explorer (window), where as each window is totally separate from others. So that I can have multiple desktop views through my single explorer. Any built in feature in .NET ?

View 11 Replies View Related

C/C++ :: How To Make Multiple Subroutine And Return Multiple Arrays

Aug 17, 2014

how to make subroutines and return multiple arrays.Before that, i wrote my program on matlab. could my program to be structured as following?

<header>
initial value of program;
subroutine1() {
calculating the first work;
return 2 or 3 arrays;

[code].....

View 14 Replies View Related

C :: Redirecting Multiple Pipes With Multiple Children

Mar 21, 2014

I've been working on a function that works like a pipeline of a shell but receives a directory, go over it an search for every file to send it to a filter, something like this in bash "cat dir/* | cmd_1 | cmd_2 | ... | cmd_N", The only problem i have with the code is the redirection of the pipe descriptors.

Code:

int main(int argc, char* argv[]){
char** cmd;
int Number_cmd;
cmd = &(argv[2]); /*list of cmds*/
Number_cmd = argc-2; /*number of cmds*/
}

[code]....

The code is seems to work fine except when i run it with more than one command in example ("./filter DIR wc rev") in this case it returns

wc: standard input: Bad file descriptor
wc: -: Bad file descriptor
0 0 0

View 2 Replies View Related

C++ ::  Multiple Files Causes (Multiple Definition) Error?

Jul 15, 2013

I'm using multiple C++ files in one project for the first time. Both have need to include a protected (#ifndef) header file. However, when I do that, I get a multiple definition error.

From what I found from research, adding the word inline before the function fixes the error. Is this the right way to do this, and why does it work? Should I make a habbit of just declaring any function that might be used in two .cpp files as inline?

View 5 Replies View Related

C++ :: Take Max Of Multiple Elements In Multiple Vectors?

Mar 1, 2012

Say I have 5 vectors of unsigned char each of size 5. I want to take the max of each index and store it in a new vector. What is the most optimal way to accomplish this?

My slow code:

Code:
vector<unsigned char> vec1;
vector<unsigned char> vec2;
vector<unsigned char> vec3;
vector<unsigned char> vec4;

[Code]....

View 3 Replies View Related

C :: GTK In Forked Process

Dec 13, 2013

I have app that has while true on input listening to changes and then in some condition needs to open simple gtk app, and afterwards continue listening.

I thought that i could fork gtk part, and kill it when it is not needed.

But am not finding much examples on internet. 2 processes dont share data. Can child process start a gui app? And is this a good approach.

View 1 Replies View Related

C/C++ :: How To Run A Process From Memory

Mar 8, 2013

I am looking for a way to run a process form memory, without having any executable. The application will be kept inside a resource and will be extracted during run time. It should be then started as a new process. I couldn't find a solution that works also on x64

View 5 Replies View Related

C :: Using Process ID As The Name Of File Directory

Jan 31, 2015

I need my Unix program to generate a directory with a format like this: "hinesro.<pid>". I have some code that mostly works, except for the directory ends up with a question mark on the end, like this: "hinesro.12345?". I need it to just display the directory without this question mark. Here is my code:

Code:

// Using headers sys/types.h, sys/stat.h, unistd.h, and stdio.h
int pid = getpid();
char prefix[] = "hinesro.";
char fileName[0];
sprintf(fileName, "%s%d
", prefix, pid);

[Code]...

View 13 Replies View Related

C++ :: Inheritance Slows Down Process

Sep 5, 2013

i have read that inheritance slows down the process.because a_class -> b_class -> c_class it goes thorough many classes to find a function or a value. people advices not to do it more than a few times. what if instead of inheritance we are using headers, would it slow down the process also??i mean which one is faster? and arent both the same when we use headers or used inheritance.

View 3 Replies View Related

C++ :: How To Create Zombie Process

Nov 25, 2014

I am looking into how to create zombie process. They are created when parent process don't call wait() and hence they are not removed from the process table. How do I create zombie process in C++? What part of the code when missed, make a process/thread zombie? Is it the pthread_join()?

View 2 Replies View Related

C# :: Multitasking On Process And Progress Bar?

Apr 9, 2015

Am developing windows forms application where in my form am fetching data into list from some object which takes around 2 minutes to complete processing so meantime i want to show progress bar before starting process till it ends with percentage. I have return a code to do multitasking but it is throwing error as "Cross-thread operation not valid: Control 'listOrg' accessed from a thread other than the thread it was created on".

private void btnOrg_Click(object sender, EventArgs e) {
try {
// To report progress from the background worker we need to set this property
backgroundWorker1.WorkerReportsProgress = true;

[code]....

View 1 Replies View Related

C# :: How To Edit Process Memory

Mar 29, 2014

I would like to ask about editing proccess memory.For example,I would like to create some program for a multiplayer game which I play.How do I work with memory adresses and what are commands for it.

View 1 Replies View Related







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