Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Octave 无法打开";文件名.txt";在八度音程中使用fopen_Octave - Fatal编程技术网

Octave 无法打开";文件名.txt";在八度音程中使用fopen

Octave 无法打开";文件名.txt";在八度音程中使用fopen,octave,Octave,如何使用倍频程中的fopen函数打开名为file name.txt的文件。我正在使用安装在windows中的octave 谢谢使用fopen打开文件并获取文件id,“r”代表读取模式 fid = fopen("name.txt", "r"); 然后使用FGET逐行检索文件并将其添加到字符串中fgets将返回-1 file_string = ""; while((line = fgets(fid)) != -1) file_string = strcat(file_string, line)

如何使用倍频程中的fopen函数打开名为file name.txt的文件。我正在使用安装在windows中的octave


谢谢

使用
fopen
打开文件并获取文件id,
“r”
代表读取模式

fid = fopen("name.txt", "r");
然后使用FGET逐行检索文件并将其添加到字符串中<一旦文件被完全读取,code>fgets将返回-1

file_string = "";
while((line = fgets(fid)) != -1)
  file_string = strcat(file_string, line);
end
完成读取后关闭文件

fclose(fid);
现在,您应该有一个变量
file\u string
,它以字符串形式包含文件内容。显然,这些实用程序比我上面描述的要多功能,因此我也鼓励您阅读以下文档:


键入:
help fopen
在Octavese中有些程序在打开名称中带有空格的文件时遇到问题。也许这就是你的问题。