blob: c5ab08b6a483329a50688db60da58331e8158c77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
// Example 12.1
// Write a program to read data from keyboard,write it to a file called INPUT,
// again read the same data from the INPUT file and display it on the screen.
warning('off');
disp("Data Input");
//Open the file INPUT
f1=mopen('INPUT.txt','w');
// Get character from keyboard
c=read(%io(1),1,1,'(a)');
mfprintf(f1,'%s',c);
//close the file input
mclose(f1);
disp("Data Output");
//Reopen the file INPUT
f1=mopen('INPUT.txt','r');
txt=mgetl(f1);
printf("%s",text);
//close the file input
mclose(f1);
|