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

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

1 Answer

0 votes
answered Aug 5 by Peter Minarik (7,160 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.