I need in c language to get to a folder like Downloads this is my path to Download folder : /run/user/1002/gvfs/mtp:host=%5Busb%3A001%2C022%5D/אחסון פנימי/Download
I have the code in java(that work)is but don't know how to do that in c:
File root2 = android.os.Environment.getExternalStorageDirectory();
File sdcard = new File(root2.getAbsolutePath() + "/download");
sdcard.mkdirs();
File file = new File(sdcard, "XYZ1.txt");
if (!file.exists()) {
try {
file.createNewFile();
}catch (IOException e) {
}
}
I would like to know how to get to Downloads folder in c language tnx for help
The equivalent C code for the above would be something like this:-
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE * fp;
FILE *fp = fopen("<relative/absolute path>/XYZ1.txt", "ab+"); //This create file if not present
if (fp==NULL){
printf("Could not create file in loc ..");
}
......
// Do your stuff with the file
......
fclose(fp); //Close the file before leaving
}
More on file IO and modes of file access here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.