Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Can I replace stdin with a piped file

+7 votes
asked Oct 31, 2019 by MarioLattanzio (190 points)
So if I was running a program that asked the user to input 50 different values and I wanted to pipe that in using a file to replace stdin, is there a way to do that on this site?  I'm using C and want to read values from a file using scanf (not fscanf) instead of entering the values in manually by piping a file in on execution.

2 Answers

0 votes
answered Dec 1, 2024 by Oliver 66 (290 points)
just use terminal (bash language), do vim myprogram.c, do i (insert) and copy and paste your code, do escape (esc) and do ':wq' (save and quit), do gcc myprogram.c, and do vim myinput, do 'i' (insert) and put in your input, and do esc again, do ':wq", and do ./a.out < myinput. Easy!
0 votes
answered Dec 2, 2024 by Peter Minarik (101,360 points)
At the bottom of the page, just above where the output is there are some options that allow you to select if you want "Interactive Console" or "Text" for input.

You can also provide command-line arguments.

Selecting "Text" should be what you're looking for.

Good luck!
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...