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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:52:09+00:00 2026-06-07T17:52:09+00:00

this type of question has been asked several times over here and elsewhere but

  • 0

this type of question has been asked several times over here and elsewhere but it seems that I don’t get any of the solutions to work. What I’ve ‘accomplished’ so far is that a variable can be used by two different applications (one application calls the other one via system command) but the value is NOT passed from the main app to the secondary one.

code corresponds to this:

 #ifndef avis_h
    #define avis_h

    #include "string"
    using namespace std;

    extern int fnu;

    #endif

that’s the header file avis_h.

The main program goes like this:

    #include "stdafx.h"
    ...
    #include "iostream"
    #include "avis_h.h"


    int fnu;

    int main(){fnu=3;system (app2);}

where app2 is the secondary application:

    #include "stdafx.h"
    ...
    #include "iostream"
    #include "avis_h.h"

    int fnu;

    int main(){cout<<fnu;Sleep(10);}

instead of the number 3 the number 0 is displayed. I’ve tried alternative ways but none worked so far. Can somebody please tell me how I get that value passed correctly from the main program to the secondary program?

  • 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-07T17:52:11+00:00Added an answer on June 7, 2026 at 5:52 pm

    You can’t share variables between independent applications like that.

    You can pass it as a parameter to the system command:

    //commandLine is app2 + " " + the parameter
    system (commandLine);
    

    Breakdown:

    std::stringstream ss; 
    ss << app2; 
    ss << " "; 
    ss << fnu;
    std::string commandLine = ss.str();
    system(commandLine.c_str());
    

    and don’t forget to:

    #include <sstream>
    #include <string>
    

    and retrieve it via argv in the second application.

    Or you can use IPC, but that’s overkill in this particular case.

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

Sidebar

Related Questions

I realize that this type of question has been asked several times before but
I know this question has been asked here before, but I don't think those
I know that this type of question has been asked over and over again,
This is a question that I know has been asked here and several other
This question has been asked on here a few times, but none of the
This is the same question that has been asked elsewhere on the site but
I know this question has been asked several times on SO, but none of
I know this type of question has been asked and answered before but I
It seems this type of question has been asked and answered a number of
This question has been asked many times before, but they all seem to relate

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.