How to resolve the algorithm File size step by step in the PL/I programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm File size step by step in the PL/I programming language

Table of Contents

Problem Statement

Verify the size of a file called     input.txt     for a file in the current working directory, and another one in the file system root.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm File size step by step in the PL/I programming language

Source code in the pl/i programming language

/* To obtain file size of files in root as well as from current directory. */

test: proc options (main);
   declare ch character (1);
   declare i fixed binary (31);
   declare in1 file record;

   /* Open a file in the root directory. */
   open file (in1) title ('//asd.log,type(fixed),recsize(1)');
   on endfile (in1) go to next1;
   do i = 0 by 1;
      read file (in1) into (ch);
   end;
next1:
   put skip list ('file size in root directory =' || trim(i));
   close file (in1);

   /* Open a file in the current dorectory. */
   open file (in1) title ('/asd.txt,type(fixed),recsize(1)');
   on endfile (in1) go to next2;
   do i = 0 by 1;
      read file (in1) into (ch);
   end;
next2:
   put skip list ('local file size=' || trim(i));
end test;

  

You may also check:How to resolve the algorithm Roman numerals/Decode step by step in the ECL programming language
You may also check:How to resolve the algorithm Palindrome detection step by step in the Zoea Visual programming language
You may also check:How to resolve the algorithm Gray code step by step in the 8051 Assembly programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the Kabap programming language
You may also check:How to resolve the algorithm Department numbers step by step in the Mercury programming language