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

  • Home
  • SEARCH
  • 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 9025229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:13:15+00:00 2026-06-16T06:13:15+00:00

I want to run another program from my C++ code. system() returns int, as

  • 0

I want to run another program from my C++ code. system() returns int, as every program can only return int to the os. However, the other program I want to call will generate a string that I need in my base app. How can I send it to the parent process?

The two apps will be in the same folder, so I think that the child app can save the string to “temp.txt” and then the main app may read and delete it (it’s not performance critical process, I will call another process just to call open file dialog in my main opengl app). However this is a bit ugly solution, are there better cross platform solutions?

Thanks

  • 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-16T06:13:16+00:00Added an answer on June 16, 2026 at 6:13 am

    You could use popen(), this opens a process where you can write and read data. AFIK this is also cross plattform

    // crt_popen.c
    /* This program uses _popen and _pclose to receive a 
     * stream of text from a system process.
     */
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void) {
    
       char   psBuffer[128];
       FILE   *pPipe;
    
            /* Run DIR so that it writes its output to a pipe. Open this
             * pipe with read text attribute so that we can read it 
             * like a text file. 
             */
    
       if((pPipe = _popen("dir *.c /on /p", "rt")) == NULL)
          exit(1);
    
            /* Read pipe until end of file. */
    
       while(!feof(pPipe)) {
          if(fgets(psBuffer, 128, pPipe) != NULL)
             printf(psBuffer);
       }
    
            /* Close pipe and print return value of pPipe. */
    
       printf("\nProcess returned %d\n", _pclose(pPipe));
    
       return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a Java program from another using ProcessBuilder I used the
If I write program in python 2.7 and I want to run another script
I want to run another Application (Polaris Office) directly from my Application. But it
I want to run a python script from within another. By within I mean
I want to pass the values from one page to another page my code
I want to compile a class from another class but every method I used
I've got a console application and I want to run it from another application.
I want to run python code from C# through command Prompt.The Code is attached
I have 100 threads. I want to run 10 thread before 10 another threads
I want run all script from the directory . Like , The directory contains

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.