Advertisement
6_2008-2009 Debugging and Error Handling #205154

Beginning C++ 4

This just for beginners. It shows how variables can exist in different scopes

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
//this program shows that variables can exist
//in different scopes and can be called on
//a peice of code within that scope

#include <iostream.h>
void main()
{
  char ch = 'A';
  cout << "Tier " << ch << '\n';
  {
   char ch = 'B';
   cout << "Tier " << ch << '\n';
   {
     char ch = 'C';
     cout << "Tier " << ch << '\n';
   }
   cout << "Tier " << ch << '\n';
  }
  cout << "Tier " << ch << '\n';
}

<?php
 $vars = array('date' => date("F d, Y"),
		 'place' => 'Nagpur',
   'name' => 'Flint Hancock',
   'language' => 'PHP',
   'grade' => 'A', );
 $new_rtf = modifier($vars, "certificate.rtf");
 $fr = fopen('output.rtf', 'w') ;
 fwrite($fr, $new_rtf);
 fclose($fr);
function modifier($vars, $rftfile) {
 $xchange = array ('\\' => "\\\\",
    '{' => "\{",
    '}' => "\}");
 $document = file_get_contents($rftfile);
 if(!$document) {
  return false;
 }
 foreach($vars as $key=>$value) {
  $search = "%%".strtoupper($key)."%%";
  foreach($xchange as $orig => $replace) {
  $value = str_replace($orig, $replace, $value);
  }
  $document = str_replace($search, $value, $document);
 }
 return $document;
 }
?>
<h2>sucessfully Generated File</h2>
Original Comments (3)
Recovered from Wayback Machine