Where does fopen open a new file?

7 ビュー (過去 30 日間)
Elisa Michelini
Elisa Michelini 2018 年 1 月 13 日
回答済み: Darshan Ramakant Bhat 2018 年 1 月 16 日
Hi everybody. I wrote a simple function in Matlab: it simply uses fopen and fprintf to open and write inside a text file (for example "file_name.txt"). Then I used Matlab Coder to generate a Dll containing this function and I tested it in Visual Studio (version 2017). No errors were showed and the .exe file has been correctly built. But, where I can find the "file_name.txt", after having run the executable? How can I test that the Matlab function has been called and the file "file_name.txt" has been created? Thank you in advance for your answers!

回答 (1 件)

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2018 年 1 月 16 日
If you are using MATLAB function directly without the dll, fopen() will create the file in the current directory. If the dll is used in Visual studio, then the fill might be created in the current execution path. However, to avoid the ambiguity, one can specify the full / relative path as the file name argument. This should created the file in the specified directory. Please refer the following documentation: https://www.mathworks.com/help/matlab/ref/fopen.html#btrnibn-3
To check the current execution path in the Visual studio refer the below stack overflow link:

カテゴリ

Help Center および File ExchangeLow-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