1. 首页
  2. 编程语言
  3. C
  4. 打开一个输出文件-恶意代码分析实战英文原版pdf

打开一个输出文件-恶意代码分析实战英文原版pdf

上传者: 2024-07-20 01:44:20上传 PDF文件 26.13MB 热度 8次

238 |第八章输入/输出函数0没有发现条目1条目为当前工作区的一个变量2条目为m文件或未知类型的文件3条目是一个MEX文件4条目是一个MDL文件5条目是一个内建函数6条目是一个p代码文件7条目是一个目录例8.4打开一个输出文件这个程序从用户那里得到输出文件名,并检查它是否存在。如果存在,就询问用户是要把用新数据覆盖这个文件,还是要把新的数据添加到这个文件中。如果这个文件不存在,那么这个程序就会很容易地打开输出文件。

% Script file: output.m

%

% Purpose:

% To demonstrate opening an output file properly.

% This program checks for the existence of an output

% file. If it exists, the program checks to see if

% the old file should be deleted, or if the new data

% should be appended to the old file.

%

% Record of revisions:

% Date Programmer Description of change

% ======= ===

% 11/29/98 S. J. Chapman Original code

%

% Define variables:

% fid -- File id

% out_filename -- Output file name

% yn -- Yes/No response

% Get the output file name.

out_filename = input('Enter output filename: ','s');

% Check to see if the file exists.

if exist(out_filename,'file')

% The file exists

disp('Output file already exists.');

yn = input('Keep existing file? (y/n) ','s');

if yn == 'n'

    fid = fopen(out_filename,'wt');

else

    fid = fopen(out_filename,'at');

end

else

% File doesn't exist

fid = fopen(out_filename,'wt');

end

% Output data

fprintf(fid,'%s ',date);

% Close file

fclose(fid);

当这个程序执行后,产生的结果为"。如果你需要进一步了解MATLAB的文件操作,可以查看以下资源:Matlab文件操作演示及示例代码MATLAB的文件操作程序,以及matlab文件操作命令详解。这些链接将为你提供更多的示例代码和操作技巧,帮助你更好地掌握文件操作。是否觉得这些资源很实用?尽快探索一下吧!

下载地址
用户评论