As we have seen in the previous problem, character strings in Pascal have fixed length. However, we treat a string as having a varying length if we ignore all trailing blanks. Consider, for example,...

fastAs we have seen in the previous problem, character strings<br>in Pascal have fixed length. However, we treat a string as<br>having a varying length if we ignore all trailing blanks.<br>Consider, for example, the following implementation:<br>CONST STRSIZE = 80;<br>TYPE STRING = RECORD<br>WORD: PACKED ARRAY [1. STRSIZE] of<br>CHAR;<br>length:1.strsize<br>END;<br>where the field length represents the position of the last non<br>trailing-blank character. For example, the string<br>'HELLOBB... 'has length 5 and 75 trailing blanks, and the<br>string 'GOODbbbBYEbbb.' has length and 70 trailing<br>blanks. Assuming the above definitions, write<br>PROCEDURE SUBSTRING (S1:STRING; var<br>S2:string; p,n: integer);<br>which copies the first n characters, starting with position p in<br>the string S1 into string S2. For example, if<br>S1='ABCDEFGHIJbbb..', then after substring (S1,<br>S2, 4, 3 ) S2 becomes ' DEFbb.'.<br>

Extracted text: As we have seen in the previous problem, character strings in Pascal have fixed length. However, we treat a string as having a varying length if we ignore all trailing blanks. Consider, for example, the following implementation: CONST STRSIZE = 80; TYPE STRING = RECORD WORD: PACKED ARRAY [1. STRSIZE] of CHAR; length:1.strsize END; where the field length represents the position of the last non trailing-blank character. For example, the string 'HELLOBB... 'has length 5 and 75 trailing blanks, and the string 'GOODbbbBYEbbb.' has length and 70 trailing blanks. Assuming the above definitions, write PROCEDURE SUBSTRING (S1:STRING; var S2:string; p,n: integer); which copies the first n characters, starting with position p in the string S1 into string S2. For example, if S1='ABCDEFGHIJbbb..', then after substring (S1, S2, 4, 3 ) S2 becomes ' DEFbb.'.

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here