why always fopen fails?

2 次查看(过去 30 天)
Aniya
Aniya 2016-10-22
回答: Jan 2016-10-22
in_file = fopen('name_of_file', 'wt');
It is my code i used to open a file .but it always return file identifier as -1.Why? Thank you for help.

采纳的回答

Jan
Jan 2016-10-22
Most likely you do not have write permissions in the current folder. Use a folder with write permissions and absolute file names:
in_file = fopen(fullfile(tempdir, 'name_of_file'), 'wt');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by