Android read text file from asset folder using C (ndk)

前端 未结 3 1338
广开言路
广开言路 2020-12-01 11:14

I need to read text file from asset folder in android, by searching through internet I found that there is asset_manager api available from android 2.3 onwards. As I am targ

3条回答
  •  眼角桃花
    2020-12-01 12:13

    Practically FILE* and 'int' descriptors are equivalent and fread/fwrite/fopen/fclose are the counterparts of open/close/read/write functions (the functions are not equivalent however, the latter are non-blocking).

    To get 'int' from 'FILE*' you can use

    int fileno(FILE* f);
    

    in header and to do the inverse you can use fdopen()

    FILE *fdopen(int fd, const char *mode);
    

    So either replace everything using the FILE* to int or just take one of the samples and insert this conversion code before the file reading.

提交回复
热议问题