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.

how do i pass a file text as a variable to my my code in onlineGDB?

–1 vote
asked Jul 29, 2020 by Tommaso Masaracchio (110 points)

1 Answer

0 votes
answered Aug 5, 2020 by Peter Minarik (84,720 points)

Use Text Input Instead of Interactive Console

When you run your code (F9), on the bottom of the page, there is a panel for

  1. command line arguments
  2. standard input
Standard input can be changed from "interactive console" to Text, where you can just copy paste your text file and use it as input for your program. (It will appear in argv of main()).

Upload Your File

You can upload files to your project. Use the button on the left of the "RUN" button. After this, you can just open your file as you'd do it normally (e.g. FILE * myFile = fopen("myfile.txt", "r");

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