IDE

Giving a program input

Programs that read something before they run need that something provided. There are four ways to do it, and they are not interchangeable.

Standard input

Text your program reads from stdin, typed before you run. Set it once and re-run against the same input while you change the code, which is why it suits debugging. A debug session is always interactive, so a program you are stepping through asks you for input as it runs rather than reading it from here.

Interactive

Run first, then answer the program as it asks, the way a terminal behaves. Use it when the program prompts, or when you want to see what a user would see.

Input arguments

Command-line arguments, given to the program as it starts. These are the argv your program already expects, not a JDoodle concept.

Files

Programs can also read files you upload and write files you take away. That has its own page, because the paths matter.

What next

Input files and generated files are the other half of this, and where the paths are written down.

This website uses cookies to ensure you get the best experience on our website.