{"id":212,"date":"2022-01-20T15:56:02","date_gmt":"2022-01-20T14:56:02","guid":{"rendered":"https:\/\/wiskunst.hjgsoft.nl\/?page_id=212"},"modified":"2022-01-24T09:37:27","modified_gmt":"2022-01-24T08:37:27","slug":"pointers","status":"publish","type":"page","link":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/","title":{"rendered":"Pointers"},"content":{"rendered":"<p>Het laatste voorbeeld van het vorige hoofdstuk, p12_5, ziet er aardig uit, maar heeft een heel groot nadeel.<br \/>\nWe hebben daar te maken met een array van records, en dit zijn zogenaamde statische variabelen.<br \/>\nDat betekent dat ze vooral al een bepaalde hoeveelheid geheigenruimte innemen, en wel binnen dezelfde ruimte als het programma zelf. Dit brengt dan ook een beperking met zich mee.<br \/>\nIn mijn situatie kan ik maar maximaal 207 records in het array kwijt. Voor een beetje adres-boek te weinig.<br \/>\nVervelend dus, zeker als je bedenkt dat er nog genoeg geheugen over is (het zgn. heap-geheugen).<br \/>\nOm daar echter bij te komen moet je gebruik maken van dynamische variabelen. Dat zijn variabelen die in de heap hun waarde krijgen.<br \/>\nHet lastige is echter dat Pascal geen boekhouding doet met dynamische variabelen. Dit zullen we dus zelf moeten doen.<br \/>\nHet voordeel van Pascal is echter wel dat we dat kunnen doen en wel door middel van pointers.<\/p>\n<h2>Voorbeeld.<\/h2>\n<p>Het voorbeeld dat in dit hoofdstuk centraal staat is wat simpeler dat p12_5.<br \/>\nWe gaan een aantal willekeurige namen genereren en die via een invoeg-procedure op de juiste, alfabetische plaats invoegen in de tot dan toe bestaande lijst.<br \/>\nHierna geven we de lijst weer op het scherm.<br \/>\nTevens bouwen we een procedure om de lijst leeg te maken en een procedure om 1 specifiek item uit de lijst te verwijderen.<br \/>\nTot slot maken we een functie die de lengte van de lijst berekent.<\/p>\n<p>Het voorbeeld gaan we zowel uitwerken met statische variabelen (zie opdrachten) als met dynamische variabelen.<\/p>\n<h2>Pointer-definitie.<\/h2>\n<p>Dynamische variabelen dienen op specifieke wijze te worden gedefinieerd.<br \/>\nKijk naar het volgende voorbeeld:<\/p>\n<p><span style=\"font-family: courier new; font-size: small;\"><b>type<br \/>\nS20 = String[20];<br \/>\nTNaamPointer = ^TNaam;<br \/>\nTNaam = record<br \/>\nNaam: S20;<br \/>\nVolgende: TNaamPointer;<br \/>\nend;<br \/>\n<\/b><\/span><\/p>\n<p>Twee dingen die (hopelijk) direct opvallen:<br \/>\nhet dakje (^) voor TNaam, en<br \/>\nTNaam wordt al als type gebruikt voordat het is gedefinieerd!<\/p>\n<p>Dit is 1 van de 2 gevallen waarin het is toegestaan om al iets te gebruiken alvorens het is gedefinieerd. (Het andere geval is d.m.v. een forward-clausule).<\/p>\n<p>Simpel gezegd is het de hond die zich in zijn eigen staart bijt.<br \/>\nEn dat is ook eigenlijk wat hier gebeurt.<br \/>\nDoor deze constructie krijgen we een ketting van variabelen, waarbij de inhoud in Naam staat, en<br \/>\nde verwijzing naar de volgende schakel in Volgende staat.<br \/>\nHet woordje &#8220;verwijzing&#8221; in de vorige zin refereert natuurlijk aan het engelse &#8220;pointer&#8221;.<br \/>\nIn Pascal is een pointer niets meer en niets minder dan een (geheugen) adres. Voor de programmeur is het niet van belang hoe dit adres eruit ziet, alleen maar dat het een adres is.<br \/>\nWel van belang is het speciale adres\u00a0<b>nil<\/b>, dat zeg maar als randaarde funcgeert. Zonder de nil is de lijst niet compleet. Je moet per slot weten waar de lijst eindigd.<\/p>\n<h2>Voorstelling van een (pointer-)lijst.<\/h2>\n<p>Vaak wordt een (pointer-)lijst voorgesteld als een gedeeld rechthoekje, met links de waarde-variabele en rechts de pointer, die met een pijl naar de volgende rechthoek wijst.<\/p>\n<p>Een deel van onze lijst zou als volgt kunnen worden weergegeven:<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-273 alignleft\" src=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer1.gif\" alt=\"\" width=\"434\" height=\"59\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>De lijst start met &#8216;Naam 1&#8217; en verwijst naar de volgende plaats, die als waarde &#8216;Naam 2&#8217; heeft en weer verwijst naar de volgende, die als waarde &#8216;Naam 3&#8217; heeft en naar\u00a0<b>nil<\/b>\u00a0verwijst, ofwel het einde van de lijst aangeeft.<\/p>\n<h2>Pointer-variabelen.<\/h2>\n<p>Om uiteindelijk met een pointer-structuur te kunnen werken hebben we pointer-variabelen nodig.<br \/>\nHierbij dient men altijd onderscheid te maken tussen de pointer-variabele zelf en de waardes die hier achter schuil gaan.<\/p>\n<p>Stel we hebben de volgende definities:<\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">type<br \/>\nt = ^integer<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 a,b: t;<\/span><\/p>\n<p>De variabelen a en b, mits niet\u00a0<b>nil<\/b>, hebben als waarde een geheugenadres.<br \/>\nOm nu bij de velden of waardes van a en b te komen, gebruiken we het dakje (^).<br \/>\nStel we willen aan a de waarde 2 en aan b de waarde 3 toekennen, dan gaat dat als volgt:<\/p>\n<p><span style=\"font-family: courier new; font-size: small;\"><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">a^ := 2;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">b^ := 3;<\/span><b><br \/>\n<\/b><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-274 alignleft\" src=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer2.gif\" alt=\"\" width=\"163\" height=\"44\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Dus a en b wijzen naar een geheugenadres, en a^ en b^ hebben een waarde!<\/p>\n<p>Dan gaan we het nu wat lastiger maken.<br \/>\nDe toekenningsopdracht a := b, is totaal verschillend van de toekenningsopdracht a^ := b^.<br \/>\nBij a := b, wordt de verwijzing van a &#8216;afgebogen&#8217; naar b.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-275 alignleft\" src=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer3.gif\" alt=\"\" width=\"163\" height=\"45\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Bij a^ := b^ wordt de waarde van b^ de waarde van a^.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-276 alignleft\" src=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer4.gif\" alt=\"\" width=\"163\" height=\"44\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Nogmaals voor alle duidelijkheid: de variabelen a en b bevatten geheugenadressen en staan in hetzelfde geheugenblok als alle andere &#8216;normale&#8217; variabelen. De waardes a^ en b^ staan in het heap-geheugen.<\/p>\n<p>Bij de toekenning a := b, gaat de waarde a^(=2) onherstelbaar verloren!<\/p>\n<h2>New en Dispose.<\/h2>\n<p>Om in Pascal goed met pointer-variabelen te kunnen werken, moet er voor deze variabelen geheugen worden gereserveerd (ge-allokkeerd).<br \/>\nDit gebeurt met de opdracht New([pointer-variabele]).<br \/>\nOm dit geheugen weer vrij te maken (de-allokkeren) gebruikt Pascal de opdracht Dispose([pointer-variabele]).<\/p>\n<p>Het is de taak van de programmeur hier zorgvuldig mee om te gaan, en ervoor zorg te dragen dat al het ge-allokkeerde geheugen weer netjes wordt vrij gegeven!<\/p>\n<h2>Terug naar het voorbeeld.<\/h2>\n<p>Om met de lijst namen te kunnen gaan werken hebben we een variabele nodig. Deze variabele geeft niets anders aan dan de start van de lijst en zullen we daarom ook LijstHoofd noemen.<br \/>\nAls de lijst leeg is heeft LijstHoofd de waarde nil, anders verwijst LijstHoofd naar het eerste element in de lijst.<\/p>\n<h6>De lijst schrijven.<\/h6>\n<p>Om de lijst te schrijven beginnen we gewoon bij het LijstHoofd en eindigen wanneer het veld Volgende de waarde nil heeft:<\/p>\n<p><span style=\"font-family: courier new; font-size: small;\"><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Schrijf;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 ref: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while ref &lt;&gt; nil do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 write(Naam:40);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 ref := Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><b><br \/>\n<\/b><\/span><\/p>\n<h6>De lijst leegmaken.<\/h6>\n<p>Om de lijst weer leeg te maken zou je kunnen denken dat de opdracht LijstHoofd := nil; afdoende zou zijn.<br \/>\nMaar dat is helaas niet zo. Het enige dat je dan doet is de eerste schakel met de lijst verbreken, waardoor de lijst inderdaad niet meer bereikbaar is. Het ernstige nadeel is nu echter dat er wel geheugen ge-allokkeerd blijft, en dat is dus niet netjes.<br \/>\nWe zullen dus iedere gebruikte variabele weer moeten vrijmaken:<\/p>\n<p><span style=\"font-family: courier new; font-size: small;\"><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Leeg;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref,refp: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while ref &lt;&gt; nil do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 refp := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 ref := Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 Dispose(refp)<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 LijstHoofd := nil;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><b><br \/>\n<\/b><\/span><\/p>\n<p>We lopen de lijst weer door vanaf LijstHoofd. Als de Volgende bestaat dan moeten we die even onthouden, refp, alvorens we naar de volgende gaan, ref. Als we bij de volgende zijn (ref), dan kunnen we de vorige (refp) veilig weghalen.<br \/>\nPas op het einde kennen we de waarde nil aan LijstHoofd toe.<\/p>\n<h6>Lengte van de lijst<\/h6>\n<p>Vaak is het handig om te weten uit hoeveel elementen een lijst bestaat, ofwel de lengte van de lijst.<br \/>\nHelaas is er geen snellere methode dan de lijst vanaf het eerste element totaan het laatste element te doorlopen en steeds een tellertje op te hogen:<\/p>\n<p><span style=\"font-family: courier new; font-size: small;\"><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">function Lengte: Integer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 a: Integer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 a := 0;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 While ref &lt;&gt; nil do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 a := a + 1;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 ref := ref^.Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Lengte := a;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><b><br \/>\n<\/b><\/span><\/p>\n<h6>Toevoegen nieuw element.<\/h6>\n<p>De voorgaande procedures en functie waren redelijk eenvoudig. Nu begint het echte werk.<br \/>\nIn ons voorbeeld willen we een element op de juiste alfabetische plaats toevoegen.<br \/>\nDe hier gevolgde strategie is als volgt:<br \/>\nDoorloop de lijst totdat er een naam wordt gevonden die groter is dan de nieuwe toe te voegen naam.<br \/>\nAls de naam kleiner is dan de toe te voegen naam moeten we die plaats onthouden, want die plaats is belangrijk als we de nieuwe naam moeten invoegen.<br \/>\nHebben we de juiste plaats, dan maken we een nieuw element met daarin de waarde van de nieuwe naam.<br \/>\nVervolgens laten we dit nieuwe element naar de volgende wijzen, en het vorige element naar dit nieuwe element.<br \/>\nHet volgende element is logischerwijs bekend, omdat we de lijst doorlopen totaan de eerste naam groter dan de nieuwe naam.<br \/>\nHet vorige element is bekend, omdat we deze expliciet hebben onthouden.<br \/>\nHier is de code:<\/p>\n<p><span style=\"font-family: courier new; font-size: small;\"><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure VoegToe(NieuweNaam: S20);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref,voorgaanderef,nieuweref: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 bepaald: Boolean;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 bepaald := false;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while not bepaald and (ref &lt;&gt; nil) do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 if nieuwenaam &lt;= naam then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 bepaald := true<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 voorgaanderef := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ref := volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 new(nieuweref);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 nieuweref^.Naam := NieuweNaam;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 nieuweref^.Volgende := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 if ref = LijstHoofd then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 LijstHoofd := nieuweref<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 voorgaanderef^.Volgende := nieuweref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><b><br \/>\n<\/b><\/span><\/p>\n<p>Schematisch ziet e.e.a. er als volgt uit:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-277 alignleft\" src=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer5.gif\" alt=\"\" width=\"434\" height=\"102\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Juiste plaats gevonden, nieuw element aangemaakt met nieuwe naam.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-278 alignleft\" src=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer6.gif\" alt=\"\" width=\"434\" height=\"102\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Laat nieuw element naar volgende element wijzen.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-279 alignleft\" src=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer7.gif\" alt=\"\" width=\"434\" height=\"104\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Laat vorige element naar nieuw element wijzen.<\/p>\n<h6>Element verwijderen.<\/h6>\n<p>Om een specifiek element uit de lijst te verwijderen volgen we min of meer dezelfde methode als bij het invoegen van een nieuw element.<br \/>\nDoorloop de lijst met elementen.<br \/>\nIs het huidige element niet het te verwijderen element, onthoud dan (de plaats van) dat element en ga naar de volgende.<br \/>\nIs het huidige element het te verwijderen element, laat dan het vorige element naar het volgende wijzen en verwijder het huidige element (Dispose).<br \/>\nAnaloog aan de vorige paragraaf zijn het vorige, huidige en volgende element bekend.<br \/>\nHier is de code:<\/p>\n<p><span style=\"font-family: courier new; font-size: small;\"><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Verwijder(VNaam: S20);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref,refp: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 bepaald: Boolean;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 bepaald := false;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while not bepaald and (ref &lt;&gt; nil) do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 if Naam = VNaam then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 bepaald := true<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 refp := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ref := Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 if bepaald then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 if ref = LijstHoofd then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 LijstHoofd := ref^.Volgende<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 refp^.Volgende := ref^.Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 Dispose(ref);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 end;<\/span><b><br \/>\n<\/b><\/span><\/p>\n<h6>De test.<\/h6>\n<p>Om \u00e9\u00e9n en ander te kunnen testen gaan we het volgende doen:<\/p>\n<p>We vullen de lijst,<br \/>\nwe verwijderen daarna het eerste element uit de lijst,<br \/>\nen dan maken we de lijst weer leeg.<br \/>\nOm te experimenteren maken we gebruik van een Constante Max die aan het begin van het programma wordt gedefinieerd.<\/p>\n<p>Het hele programma ziet er als volgt uit:<\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">program dynamis;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">const<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 MaxNamen = 3000;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">type<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 S20 = String[20];<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 TNaamPointer = ^TNaam;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 TNaam = record<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 Naam : S20;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 Volgende: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 LijstHoofd: TNaamPointer;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Schrijf;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 ref: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while ref &lt;&gt; nil do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 write(Naam:40);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 ref := Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Verwijder(VNaam: S20);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 ref,refp: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 bepaald: Boolean;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 bepaald := false;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while not bepaald and (ref &lt;&gt; nil) do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 if Naam = VNaam then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 bepaald := true<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 refp := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ref := Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 if bepaald then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 if ref = LijstHoofd then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 LijstHoofd := ref^.Volgende<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 refp^.Volgende := ref^.Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 Dispose(ref);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Leeg;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref,refp: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while ref &lt;&gt; nil do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 refp := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 ref := Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 Dispose(refp)<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 LijstHoofd := nil;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure VoegToe(NieuweNaam: S20);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref,voorgaanderef,nieuweref: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 bepaald: Boolean;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 bepaald := false;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 while not bepaald and (ref &lt;&gt; nil) do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 with ref^ do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 if nieuwenaam &lt;= naam then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 bepaald := true<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 voorgaanderef := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ref := volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 new(nieuweref);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 nieuweref^.Naam := NieuweNaam;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 nieuweref^.Volgende := ref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 if ref = LijstHoofd then<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 LijstHoofd := nieuweref<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 else<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 voorgaanderef^.Volgende := nieuweref;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">function Lengte: Integer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref: TNaamPointer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 a: Integer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 ref := LijstHoofd;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 a := 0;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 While ref &lt;&gt; nil do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 a := a + 1;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 ref := ref^.Volgende;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Lengte := a;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Lijst(aantal: Integer);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">var<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 i,j: Integer;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 s: S20;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Leeg;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 for i := 1 to aantal do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 s := &#8221;;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 for j := 1 to 20 do<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 \u00a0 s := s + Chr(97+Random(26));<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 \u00a0 VoegToe(s);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 \u00a0 end;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Schrijf;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">procedure Test;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 clrscr;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Lijst(MaxNamen);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 writeln(&#8216;Lengte=&#8217;,Lengte);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Verwijder(LijstHoofd^.Naam);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 writeln(&#8216;Lengte=&#8217;,Lengte);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Leeg;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 writeln(&#8216;Lengte=&#8217;,Lengte);<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end;<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">begin<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 LijstHoofd := nil;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">\u00a0 Test;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace; font-size: 12pt;\">end.<\/span><\/p>\n<h2>Oefeningen.<\/h2>\n<p><a name=\"13.1\"><\/a><b>13.1<\/b><br \/>\nMaak hetzelfde test-programma als in dit hoofdstuk, maar nu met statische variabelen, ofwel met een record-structuur.<br \/>\nVergelijk beide programma&#8217;s op uitvoer en tijds-duur.<\/p>\n<p> [<a href=\"https:\/\/wiskunst.nl\/index.php\/programmeren\/oefeningen\/#13.1\" target=\"_blank\" rel=\"noopener\">Antwoord<\/a>]\n<p> [<a href=\"https:\/\/wiskunst.nl\/index.php\/programmeren\/gestructureerde-types\/\">Gestructureerde types<\/a>] &lt;&#8211; &#8211;&gt; [<a href=\"https:\/\/wiskunst.nl\/index.php\/programmeren\/rijen-en-stapels\/\">Rijen en stapels<\/a>]\n","protected":false},"excerpt":{"rendered":"<p>Het laatste voorbeeld van het vorige hoofdstuk, p12_5, ziet er aardig uit, maar heeft een heel groot nadeel. We hebben daar te maken met een array van records, en dit zijn zogenaamde statische variabelen. Dat betekent dat ze vooral al een bepaalde hoeveelheid geheigenruimte innemen, en wel binnen dezelfde ruimte als het programma zelf. Dit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":185,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"templates\/template-full-width.php","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"class_list":["post-212","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pointers - Wiskunst<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pointers - Wiskunst\" \/>\n<meta property=\"og:description\" content=\"Het laatste voorbeeld van het vorige hoofdstuk, p12_5, ziet er aardig uit, maar heeft een heel groot nadeel. We hebben daar te maken met een array van records, en dit zijn zogenaamde statische variabelen. Dat betekent dat ze vooral al een bepaalde hoeveelheid geheigenruimte innemen, en wel binnen dezelfde ruimte als het programma zelf. Dit [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/\" \/>\n<meta property=\"og:site_name\" content=\"Wiskunst\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-24T08:37:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer1.gif\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschatte leestijd\" \/>\n\t<meta name=\"twitter:data1\" content=\"10 minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/\",\"url\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/\",\"name\":\"Pointers - Wiskunst\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wiskunst.nl\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/pointer1.gif\",\"datePublished\":\"2022-01-20T14:56:02+00:00\",\"dateModified\":\"2022-01-24T08:37:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wiskunst.nl\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/pointer1.gif\",\"contentUrl\":\"https:\\\/\\\/wiskunst.nl\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/pointer1.gif\",\"width\":434,\"height\":59},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/pointers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wiskunst.nl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programmeren\",\"item\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Programmeren met Pascal\",\"item\":\"https:\\\/\\\/wiskunst.nl\\\/index.php\\\/programmeren1\\\/programmeren\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Pointers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wiskunst.nl\\\/#website\",\"url\":\"https:\\\/\\\/wiskunst.nl\\\/\",\"name\":\"Wiskunst\",\"description\":\"2\u221e\u2227&gt;\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wiskunst.nl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-NL\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pointers - Wiskunst","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/","og_locale":"nl_NL","og_type":"article","og_title":"Pointers - Wiskunst","og_description":"Het laatste voorbeeld van het vorige hoofdstuk, p12_5, ziet er aardig uit, maar heeft een heel groot nadeel. We hebben daar te maken met een array van records, en dit zijn zogenaamde statische variabelen. Dat betekent dat ze vooral al een bepaalde hoeveelheid geheigenruimte innemen, en wel binnen dezelfde ruimte als het programma zelf. Dit [&hellip;]","og_url":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/","og_site_name":"Wiskunst","article_modified_time":"2022-01-24T08:37:27+00:00","og_image":[{"url":"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer1.gif","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Geschatte leestijd":"10 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/","url":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/","name":"Pointers - Wiskunst","isPartOf":{"@id":"https:\/\/wiskunst.nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/#primaryimage"},"image":{"@id":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/#primaryimage"},"thumbnailUrl":"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer1.gif","datePublished":"2022-01-20T14:56:02+00:00","dateModified":"2022-01-24T08:37:27+00:00","breadcrumb":{"@id":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/#primaryimage","url":"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer1.gif","contentUrl":"https:\/\/wiskunst.nl\/wp-content\/uploads\/2022\/01\/pointer1.gif","width":434,"height":59},{"@type":"BreadcrumbList","@id":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/pointers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wiskunst.nl\/"},{"@type":"ListItem","position":2,"name":"Programmeren","item":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/"},{"@type":"ListItem","position":3,"name":"Programmeren met Pascal","item":"https:\/\/wiskunst.nl\/index.php\/programmeren1\/programmeren\/"},{"@type":"ListItem","position":4,"name":"Pointers"}]},{"@type":"WebSite","@id":"https:\/\/wiskunst.nl\/#website","url":"https:\/\/wiskunst.nl\/","name":"Wiskunst","description":"2\u221e\u2227&gt;","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wiskunst.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"}]}},"_links":{"self":[{"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/pages\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/comments?post=212"}],"version-history":[{"count":8,"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/pages\/212\/revisions"}],"predecessor-version":[{"id":542,"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/pages\/212\/revisions\/542"}],"up":[{"embeddable":true,"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/pages\/185"}],"wp:attachment":[{"href":"https:\/\/wiskunst.nl\/index.php\/wp-json\/wp\/v2\/media?parent=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}