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 to call a function from another file in this online compiler? C

+9 votes
asked Mar 2, 2021 by Elva Margarita Madrid GarcĂ­a (210 points)
with C language. How can I call a function from another program here? Please help. Thanks in advance!

2 Answers

+2 votes
answered Mar 2, 2021 by Peter Minarik (86,040 points)

You can have multiple files in your OnlineGDB project. So you'd just do it as normally you'd do.

Write your (non-static) function in a separate file. Use extern to include that function from your main source file. Or, create a header for it and include that header file.

Here is a small example I created for you.

Good luck!

+1 vote
answered Mar 2, 2021 by 201803100910040 Vipul Dangodra (170 points)
To use a function in another file, you need to declare it. Usually, every . c file (except main. c) has an associated header
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.
...