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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:06:44+00:00 2026-06-05T10:06:44+00:00

I created a random integer generator program. It takes in two arguments, a max

  • 0

I created a random integer generator program. It takes in two arguments, a max number and a min number, and spits out a random integer within that range including both ends.

I am creating simulation programs in which I need random integer numbers and I want to be able to call the randomizer program and pass the max and mins I need for the simulation program to it and then return the random number to the simulation.

I just do not know and can not find the code I would need to write in the simulation to bring up the randomizer AND pass it the max and min values.

Thank you!

  • 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-05T10:06:46+00:00Added an answer on June 5, 2026 at 10:06 am

    For your specific question, you should consider using popen(). Make sure to call pclose() after your are finished reading in your result.

    FILE *input = popen("program -and args", "r");
    if (input) {
      // read the input
      pclose(input);
    } else {
      perror("popen");
      // handle error
    }
    

    If the program is reading its arguments from standard input, and then outputting the result to its standard output, you will need to create a bidirectional version of popen. Assuming you have a POSIX compliant OS, socketpair could be used to create your bidirectional channel (alternatively, you could make two calls to pipe). Then you would implement the functionality using fork and then one of the exec variants. This is discussed here.

    But, as suggested by others, you should really just incorporate the functionality of your random number generator into your program as a function.

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

Sidebar

Related Questions

I want to create a Qt application that takes a random integer and sends
Suppose you have a random number generator that generates a random floating point number
I created a simple program that uses condition variables to create synchronization between two
I am trying to create a function that generates a random integer out of
I created a test application that generates 10k random numbers in a range from
I created a sunny sky with two objects following a random transparent path with
How to create a function, which on every call generates a random integer number?
I am writing a multi-threaded Java program that generates lot of random numbers. Additional
I have a random math generator and a .get command that sets the value
I m trying to make a random number generator in android. My code has

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.