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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:53:52+00:00 2026-06-01T21:53:52+00:00

So basically what I need isn’t a specific code (of course that would be

  • 0

So basically what I need isn’t a specific code (of course that would be great), but just an idea and methods on how to achieve my goal.

1) I have to create a program in C++ , which generates a little example of C++ code, that is each time a bit different. (This causes no problems for me, I will use a template and randomize some variables in the code, which will make it unique every time.)

2) I will display the generated code and the user will have to type in, what he thinks the code prints out.

And here is where the problems start:

3) I have to take the generated code and compile it somehow to get a string with the text that the program would have printed out.

4) And then compare the string with what the user has typed in.

So the step 3) is where I stop and can’t figure it out without help… I was thinking to write the generated code in a function of a .cpp file and then call that function, but I couldn’t get it to work, so I started to think, I should ask an expert, maybe there are some other methods or ideas how to achieve this.

  • 1 1 Answer
  • 1 View
  • 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-01T21:53:54+00:00Added an answer on June 1, 2026 at 9:53 pm
    1. Write the .cpp file
    2. invoke the compiler (or make or equivalent build system)
    3. if compilation fails, presumably display the errors?
    4. if compilation succeeds, run the resulting program and display the output

    It’s probably simplest to wrap 2/3/4 into a script, and invoke that with system or popen. The script can make sure the filenames are unique, fold stderr into stdout, etc. etc.

    Your running program isn’t really interacting with the compiled code, just reading the output, so keeping it as a seperate process is probably easiest. The script can add some markup to help you distinguish compiler output/errors from the program output.


    I haven’t written a batch file for years, but once you know how to run your compiler from the command line (ref), you can write a script to:

    1. compile a .cpp file
    2. execute the resulting .exe
    3. redirect its output to a file

    then, in C++ you just need to save the code to the .cpp file the script expects, execute the script like system("myScript.bat"), and then read the output file.

    If you don’t want to write a seperate batch script, you can just call system once to invoke the compiler, and again to execute the resulting .exe.

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

Sidebar

Related Questions

basically need to change the value that - admin_url() returns any idea?
Here is my code, basically its written so that all you need to do
Basically I need to setup my ASMX file so that when I pull it
So basically I need to make feature that if you select something from first
here is the code: http://jsfiddle.net/hQnXm/7/ So basically i need when hover, it should animate
here is some code I've been working on, basically I need to set up
I have the following data that basically I only need a few bits of
Basically I need to check if a table is locked from my code. I
I have a need to create an integer value to a specific power (that's
OK, this isn't really a question to achieve anything practical, but still it is

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.