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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:18:59+00:00 2026-06-05T05:18:59+00:00

Ok suppose I have a program ( in windows a .exe file ) and

  • 0

Ok suppose I have a program ( in windows a .exe file ) and when I run it, it outputs some information… now I’m writing another program ( in c++ ) and I need it to automatically run that .exe file and read the output so that it can process that information for further actions…

what should I do ?

  • 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-05T05:19:00+00:00Added an answer on June 5, 2026 at 5:19 am

    Use popen or on windows (per comment) _popen. Basically it functions as the thing behind the | in some program | thing.

    Normally I’m against posting complete code but I literally wrote this today and have it on hand, so, here you go. From what I understand C++ doesn’t have a great interface that replaces popen but if you’re bringing in the boost libraries or something at that layer there are solutions.

    Note I use char[10] because in my application I know the output will be that short.

       PopenWrapper(const std::string& command) {
    
                fd = popen(command.c_str(), "r");
                if(fd == NULL) {
                        throw PopenException("Failed to open command: " + command);
                }
        }
    
        std::string get() {
                char line[10];
                fgets(line, sizeof(line), fd);
                return std::string(line);
        }
    
        ~PopenWrapper() {
                if(fd != NULL) {
                        pclose(fd);
                }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have this: <Window stuff Icon=Resources\myicon.ico> If I run the program on Windows
I have a requirement such that my program is suppose to run for a
everyone, Suppose I have a simple JNI program in Windows: int* p = NULL;
Suppose I have a program that initializes a global variable for use by threads,
Suppose I have a big program that consists of hundreds of methods in it.
I have a small program that's supposed to sample some value from a device
I have Beyond Compare 3 installed at; C:\Program Files\Beyond Compare 3\BCompare.exe and Cygwin; C:\Cygwin\bin\bash.exe
I have many C/C++ old native .exe and .dll programs running on Windows servers
Suppose I have pointer of type ABC* and another pointer of type XYZ* and
In Windows, suppose you have multiple windows (HWNDs) of the same window class open.

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.