fscanf 函数
从文件或描述符读取格式化值。
语法
fscanf(file, format)
参数与选项
file | 文件名或描述符。 |
|---|---|
format | 使用 %d、%f 或 %s 转换说明的格式。 |
示例
- 读取格式化记录
fremove('doc_io_scan.txt'); fprintf('doc_io_scan.txt', 'Item %d costs %.2f\n', 3, 4.5); row := fscanf('doc_io_scan.txt', 'Item %d costs %f\n'); fremove('doc_io_scan.txt'); row返回 [3, 4.5]。