C++ :: Running Same Code With Different Inputs On Multiple CPUs

May 28, 2014

I have a C++ code reading large data from an input txt file, doing some calculation on the data, and writing the result of calculation in another txt file.

I have about 300 input files, and the calculation time for each input file is pretty long (~4 days on a single CPU), so I would like to run the same code on multiple CPUs for different inputs.

Which is the most appropriate strategy in this case, multithreading, mpi or something else?

View 4 Replies


ADVERTISEMENT

C++ :: Using Cin That Accept Multiple Inputs

Feb 14, 2013

For a program I am required to use a cin that accepts 4 variables. The first describes a function such as add(), remove(), print(), or quit(). The problem is that to use add() I need to input all 4 variables but for remove(), only 2 variable input is needed.

I want the input to be "add 9 James Bond"
or be "remove 341"

Here is my current code.

int command(string command, int Id, string first, string last){
while (command != "quit"){
cout << "customers> ";
cin >> command >> Id >> first >> last;
if (command == "add")

[Code] .....

View 1 Replies View Related

C :: Processing Outputs Of Multiple Inputs

Nov 26, 2013

It's not something trivial but I would like to know the best way to process multiple outputs, for example:

Input
First line of input will contain a number T = number of test cases. Following lines will contain a string each.

Output
For each string, print on a single line, "UNIQUE" - if the characters are all unique, else print "NOT UNIQUE"

Sample Input
3
DELHI
london
#include<iostream>

Sample Output
UNIQUE
NOT UNIQUE
NOT UNIQUE

So how can I accomplish outputs like that? My code so far is:

Code:
int main(int argc, char *argv[]) {
int inputs, count=0;
char str[100];
char *ptr;
scanf("%d",&inputs);

[Code] ....

But the above will obviously print the output after each input, so I want to know how can I achieve the result given in the problem. Also another thing I want to know is, I am using an array of 100 char, which it can hold a string up to 100 characters, but what do I have to do if I want to handle string with no limit? Just declaring char *str is no good, so what to do?

View 5 Replies View Related

C :: Reading Multiple Inputs Sscanf

Jan 23, 2014

I am beginner at C and I was working on a program where I have to read in a line such as Digit, String, Float. The string can have any amount of spaces between it. and each input is separated by a space character.

The input is of the format:

10000000000 hello my n ame is 30.2

So I used fgets(x,100,stdin) to read the line in.

So I need to read that line into an int, array, and float.. so I was thinking of using this:

sscanf(x, "%d %[^/n] %f", &number, &username, &numberfloat);

Now, obviously I can't use the /n to read in the username with spaces because I need to read the 30.2 into a float variable.

View 5 Replies View Related

C++ :: How To Access Certain Elements And Store Multiple Inputs

Jan 20, 2014

am trying to create a program that asks the user personal questions.

std::vector<std::string> name, age, favsinger;
std::cout << "Hello, what is your Name Age Favorite_Singer? ";
std::cin << name; //i want to store the user's info along with the sibling's

[Code]....

View 4 Replies View Related

C/C++ :: Record Multiple Inputs For 2 Orders On 2 Different Registers?

Feb 26, 2015

The tools Hal's sells are: Hammers: $10.99 Wrenches: $10.99 Levels: $19.99 Tape Measures: $4.99 Screwdrivers: $8.99

In order to make things easier in the long run you have decided to make a c++ program that takes in all the orders for each register and tallies them at the end of the day.

Write a c++ program that does the following:

Create a Register class that can store all of the receipts for the day and the totals for that register.

This class could have the following member functions:

Contructor(int) - Creates a number of receipts based on an integer that is passed into the constructor (this is the largest number of orders that the register can take). You may also be required to create additional variables to make the program work but that's up to you to determine.

void getorder() - Asks the user how many of each item they want an stores that in the first available receipt.

void returnreceipts() - This function returns the details of all the receipts and the total for the day.

Register operator+(const Register &right)- This is an overloaded addition operator. When two objects are added together an empty temporary register is created (with 0 receipts) and only the totals of both objects are added to it. The temporary register is returned by the function.

Register operator=(const Register &right)- This overloaded assignment operator copies only the totals from the Object on the right.

In the Main function I would like:

Create 3 Register Objects. The first two registers are the ones in the store and should be initialized to take 10 orders. The third is used at closing time and can be initialized with 0 receipts as it will only take in the totals from the other registers.

Run the getorder function for registers 1 and 2 twice.
Run returnreceipts for register 1 and register2.
Reg3=Reg1+Reg2;
Run returnreceipts for register 3.

[Code]...

this is what I have so far I'm trying to get the input part working first, so the user would be asked each item individual how many they want? this will happen for 2 users, then the next register will do the same?

View 2 Replies View Related

C++ :: Running Certain Code In Codeblocks Sets Off AVG?

Jul 3, 2012

I've recently started to learn C++ and I'm using codeblocks as my IDE, but I keep getting problems with AVG free edition picking up random pieces of code as Trojans ?! I've put an example of some code that sets it off below, and the error message I get. Is there anyway I can set AVG not to trigger with any codeblocks coding I've done? I guess I could tell AVG not to trigger for that folder, if that's even possible?

Code:

#include <iostream>
using namespace std;
class MyClass{
public:
void coolSaying(){
cout << "BUST A MOVE!!" << endl;

[Code] ....

Error I get:

File name: h:DesktopC++ projectsclasses and objects 1 inDebugclasses and projects 1.exe
Threat name: Trojan horse Agent3.BMSZ
Detected on open.

View 14 Replies View Related

C/C++ :: Running Multiple Terminal In Xcode

Oct 5, 2014

I am using Xcode to do c++ programming and I have a c++ code, with different input arguments. I want to achieve that in Xcode, I could run multiple simultaneous running of my c++ code. However, the current problem is that once one code finishes, its terminal window automatically closed and I do not have time to look at its result. Thus computer time is wasted. Is there a way to run multiple same c++ code with different arguments input?

View 6 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++ :: Code Not Running Properly - Unresolved Externals

Mar 6, 2013

My code won't run properly. The error says unresolved externals.

#include <iostream>
#include <cstring>
using namespace std;
char again;
void reverse(char*);

[Code] ....

View 2 Replies View Related

C++ :: Ball Collecting Game - EXE Not Running Outside Code Blocks

Apr 13, 2014

I have created a game.It is working fine in codeblocks, but when I am trying to run it outside codeblocks, it opens and closes immediately. I have pasted all the necessary files and dlls in root folder and debug folder. Here is the code:-

#include <iostream>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <sstream>

const int WINDOWS_Height = 480;
const int WINDOWS_Width = 640;

[Code] .....

View 2 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++ :: How To Get Code To Read Multiple Input Values

Feb 10, 2013

So I have to write a code for my C++ class, and I am having a problem trying to figure out how to get my code to read multiple int values. This is what my code should look like

Enter two times in military format (e.g., 1730 1520): 1730 1520
[1520<1730]
Enter two times in military format (e.g., 1730 1520): 1520 1730
[1520<1730]
Enter two times in military format (e.g., 1730 1520): 1730 1730
[1730==1730]
Enter two times in military format (e.g., 1730 1520): 1760 1520
1760: [INVALID TIME 1]
Enter two times in military format (e.g., 1730 1520): twelve 2
[INVALID NUMERIC INPUT]

View 1 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 :: Print Out - Array Code And Pseudo Code?

Apr 15, 2013

I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.

View 2 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++ :: The Max Of N Inputs That Is Divisible By 3

Nov 29, 2013

Code:
#include <stdio.h>
int main(){
int A, B;
char decision;
printf("Do you have an integer to input? [Y/N]: ");
scanf("%c",&decision);
if(decision=='Y' || decision=='y'){

[Code]....

After entering a single integer, it doesn't scan again for another integer. What's wrong?

I'm using a mac btw, if that makes a difference with Ubuntu/Linux.

View 8 Replies View Related

C :: How To Read Inputs From File

Dec 7, 2014

I have learnt recently how to use fgetc, fputc, fputs, fgets but still I am not able to figure out how to read values from a file like for example:

12 14 1928 32993932
17 98
166 109 201

These are separate integers & i want to read them and then manipulate these individual integers like going for 2*I1, 4*I2 and so on where I1 and I2 are 12 & 14.

View 2 Replies View Related

C :: 2 User Inputs For Calculation

Apr 9, 2014

I want to have calculations take place inside a switch statement that calls the appropriate function. The menu portion of the program works well, but I can't figure out how to let the user actually input 2 different numbers to the functions. My questions are:

1. If I use scanf to assign values to the variables, what determines end of input to each variable? (ie.. scanf("%d%d", &a, &b) what is the end of a, what is the end of b?)

2. Should I assign the variables to user input inside the switch, or try to do it in the functions below?

3. Is there something I haven't thought to ask that will screw me over? I'm really new to this.

Code:
#include<stdio.h>
int add(int b, int a);
int mult(int b, int a);
main() {

[Code] ....

This really was a test of multilayer menu, but I want to add functionality if I can.

Changed a variable before posting and didn't change all the conditions testing it.

View 3 Replies View Related

C :: Keep User From Putting Inputs

Sep 27, 2013

On my program I use a counter to count to 10, then i ask for a string, in this case "yes" or "no", during the count, i want to keep the user from putting inputs in, due to the fact that if they put both "yes" and "no" before the program reads the string.

Code:

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <string.h>
}

[code]....

View 3 Replies View Related

C :: Skips Inputs Instead Of Inputting Last Name

Mar 2, 2014

it skips the input phase,, instead of inputting the last name it goes directly to the firstname then middle initail and street name are working fine but it skips the street name then goes to city and so on....

Code:

char l[50], f[50], m;char strtname[50], cty[50], cntry[50];
int strtnum, zp, i;
system("cls");
printf("Enter Last name:");
gets(l);
printf("
Enter First name:");
}

[code]....

View 3 Replies View Related

C :: How To Put What The User Inputs Into Array

Jul 23, 2014

I have a project that requires I take user input from menu options and put it into an array which I will average out. I can set the menu up I think, but I cannot understand how to put what the user inputs into an array. Granted I just took the lecture on arrays today. Also we can only use functions to do the work.

View 9 Replies View Related

C :: How To Scanf Inputs Into Array

Nov 23, 2014

I don't know how many numbers will be the input only that its going to be up to 10000. EOF should be active. I tried it like this:

Code:

int i = 0;
int del[10000]
while (scanf("%d",del[i])!=EOF)
{
i++;
}

But it seems the value of i doesn't increment, could you provide some tips on how to scanf the inputs into an array if I don't know how many numbers will I have?

View 7 Replies View Related







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