Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6741489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:43:52+00:00 2026-05-26T11:43:52+00:00

In order to execute a program multiple times based on the user input, I

  • 0

In order to execute a program multiple times based on the user input, I need to vary the arglist array sent to the execution function. For the most part, I have it working, except for setting the final flag to signify which split function to use from information gain, first index and gini coefficient

This program has three different split functions to create a decision tree based on a training and testing dataset. I set up the arglist to mimic the traditional CLI input so these are valid inputs:

./decision voting 5

./decision -train voting-train-1 -test voting-test-1 -out voting.out -[i, s, g]

What the first command does is executes all three split functions on all voting-– files from 1 to 5, whereas the second does it with a singular dataset.

I have a temp arg array which is built depending on the iteration, and when it comes time to add the final flag, this is what I’ve done:

//flag pointers
char *igFlag= "-i";
char *faFlag= "-s";
char *giFlag= "-g";

//copy temp array to specific arglist
igInput= cli;
faInput= cli;
giInput= cli;

//set information gain flag and null
igInput[7]= igFlag;
igInput[8]= '\0';

//set first attribute flag and null
faInput[7]= faFlag;
faInput[8]= '\0';

//set gini coefficient and null
giInput[7]= giFlag;
giInput[8]= '\0';   

The issue here is when faInput[7]= faFlag executes, it changes igInput[7] to match and then when giInput[7]= giFlag is executed, all three arrays have matching [7] pointers.

I came across a similar issue when using the same temp pointer for a integer array, but that issue was fixed via using differently named variables. This issue is happening even though I have distinct variables that have nothing to do with each other.

SOLVED

In response to AusCBloke’s request to know how I solved this problem, here goes.

First, I decided that I didn’t need multiple input strings, just the one where the last slot was to be modified. So I cut away two of the xxInput strings and used only one.

I ended up needing more flags at the end, and rather than end up with duplicate code, I created a char flag[5] containing the flags to be used. These were then called from inside a for loop, where the flag used was the current index value.

All in all, this approach ended up removing about 30 lines of un-needed code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:43:52+00:00Added an answer on May 26, 2026 at 11:43 am

    You’re making something trivial into a nightmare. My understanding is that you want to run the command 3 times, with -i, -s, or -g depending on the iteration. So do this:

    char opt[] = "-i", *cmd[] = {
        "decision", "-train", "voting-train-1", "-test", "voting-test-1",
        "-out", "voting.out", opt, 0
    };
    /* use first command line */
    opt[1] = 's';
    /* use second command line */
    ops[1] = 'g';
    /* use third command line */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

guys. In my program, i need to execute a kmlsample.exe in CMD, right now,
What's the execute order of the different parts of a SQL select statement? Such
I wanted to choose the order to execute the JUnit tests. I have 4
I am trying to emulate a web browser in order to execute JavaScript code
Aren't Javascript blocks supposed to execute in the order that they are placed on
I wanted to know how PHP would execute this. Order of operations addslashes(strip_tags($record['value'])); Is
It can be anoying that jQuery event handlers always execute in the order they
In my program, I need to run a external command in a Ubuntu environment
I've got a GUI C++ program that takes a shell command from the user,
I have a program, a part of which executes a loop. During the execution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.