view readFile.m @ 3:ace890ed0ed9 default tip

Use lookup to look for all words at once
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Sat, 10 Dec 2011 15:56:02 -0500
parents f602dc601e9e
children
line wrap: on
line source

function file_contents = readFile(filename)
%READFILE reads a file and returns its entire contents 
%   file_contents = READFILE(filename) reads a file and returns its entire
%   contents in file_contents
%

% Load File
fid = fopen(filename);
if fid
    file_contents = fscanf(fid, '%c', inf);
    fclose(fid);
else
    file_contents = '';
    fprintf('Unable to open %s\n', filename);
end

end