home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / chap15 / simpmem / simpmem.dpr next >
Encoding:
Text File  |  1995-03-21  |  578 b   |  27 lines

  1. program SimpMem;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: SIMPMEM }
  5.  
  6. { A very simple program showing how to allocate
  7.   and deallocate memory for a pointer to a string. }
  8.  
  9.  
  10. {$IfDef WINDOWS}
  11. uses
  12.   WinCrt;
  13. {$EndIf}
  14.  
  15. type
  16.   PString = ^String;
  17.  
  18. var
  19.   MyString: PString;
  20.  
  21. begin
  22.   New(MyString);        { Allocate 256 bytes for the string }
  23.   MyString^ := 'Hello'; { Assign a value to string          }
  24.   WriteLn(MyString^);   { Write the value to the screen     }
  25.   Dispose(MyString);    { Deallocate the memory             }
  26. end.
  27.