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.

open a text file

0 votes
asked Feb 28, 2019 by jacques sap (120 points)
I am under android.

I have a file "file:///storage/emulated/legacy/download/dico.txt"

I open it    dico = fopen("///storage/emulated/legacy/download/dico.txt","r");

or

   dico = fopen("file:///storage/emulated/legacy/download/dico.txt","r");

I get dico == 0 in both cases.

How can I get the right path ?

2 Answers

–1 vote
answered Mar 18, 2019 by jamiuy (170 points)
Layout:

Text:

Text'1'

Number one is an example for an text
0 votes
answered Mar 20, 2019 by Dion Houston (240 points)
This is just an educated guess :)

If this is the fopen from the Android Kernel, I suspect it natively doesn't handle the file:// URI format.That's where the three slashes come in.

Try:

 dico = fopen("/storage/emulated/legacy/download/dico.txt","r");

And see if that gives you a different result...
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.
...