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 8005407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:13:22+00:00 2026-06-04T17:13:22+00:00

I need to have an input that looks like ./a.out <exe> <arg1> … <argn>

  • 0

I need to have an input that looks like

./a.out <exe> <arg1> ... <argn> <others_stuff>

where <exe> <arg1> ... <argn> is the input that I must execute as a separate process (the objective is to save the exe’s output into a txt).

Saving output into a txt file isn’t a problem, I just have to redirect stdout (using dup2, freopen, or something similar).

The problem is to execute just a portion of argv! Because exec’s family functions (they are so many!) let to give as input whole argv, or specifying each arg.
I’m writing over here because I can’t solve the problem, so I hope you’re going to help me (I googled everywhere with no success).

EDIT: I forgot to say that i cannot use system for execute the command!

  • 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-06-04T17:13:24+00:00Added an answer on June 4, 2026 at 5:13 pm

    Since exec accepts an argv argument as a char* array terminated by a NULL pointer, you can just use the existing argv and set the member after the last one you want to pass to NULL.

    This does destroy argv – if that’s a problem, you can copy it first (you’ll have to allocate some memory for the new copy…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some input that looks like the following: A,B,C,"D12121",E,F,G,H,"I9,I8",J,K The comma-separated values can
I have a table that looks like this: <table name=exercises id=workout-table> <tr> <th>Name</th> <th>Reps/Intervals</th>
Let's say I have an XML file that looks like this: <a id=x> <b>
I have a form that looks something like this <form action=# class=ajax_form method=post id=comment_form
If I have a model named Client and controller that looks like this class
I have a series of dynamically generated inputs that I need to have ajax
I have input text: <div><label wicket:for=name>Name</label><input type=text wicket:id=name /></div> Now I need to add
I have a string input from which I need to extract simple information, here
I have a page where I need to capture input from a user after
I have a console application where I need to input numbers until enter x.

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.