


























Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!



























1
BINARY FILES
00000000 00000000 00000000 10000111 00000000 00000000 00000001 10000110
1 st^ value ( 135 ) 2 nd^ value (^390 )
00000000 00110001 00000000 00110011 00000000 00110101 00000000 00110011
1 st^ value ( 135 )
%% Unit 8. Functions
fileName='myFile.txt'; fid=fopen(fileName,'wt'); % open file in write mode % fid is the file identifier % If fopen cannot open the file, then fileID is -1.
if fid ~= - a=input('Enter first number:\n'); b=input('Enter second number:\n');
fprintf(fid, 'Numbers entered are %i and %i\n', a,b);
result=fclose(fid); % close file end
% binary file fileName='myFile2.bin'; fid=fopen(fileName,'w'); % open binary file in write mode
if fid ~= - fwrite (fid, [a,b]); result=fclose(fid); % close file end
% binary fileName='myFile2.bin'; fid=fopen(fileName,'r'); % open binary file in read mode if fid ~= - matrix=fread (fid); result=fclose(fid); % close file end
record 1 record 2 record 3 …
Beginning of file (^) Current position End of file