Chaga Programming Language: Chapter 7: Input and Output

getchar

function getchar (void) return (unsigned char, int)

  • The getchar function returns an unsigned character to identifier1 upon success. If an error occurred, getchar returns an integer value -1 to identifier2.
  • set (identifier1, identifier2) = getchar (void);

putchar

  • The putchar procedure sends one unsigned character from expression to standard output.
  • procedure putchar (expression)
  • Example: call putchar (byte);
  • Example: call putchar ('\t');
  • Example: call putchar ("\n");

memory_allocate

  • The memory_allocate function requests a chunk of heap memory from the operating system. The amount of memory is calculated based upon the datatype times the number of number of records of that datatype. If the datatype is an enum datatype, the size of the datatype will be determined by the datatype in the enumerated list that requires the most amount of storage.
  • Upon success, the memory_allocate function returns a pointer to the memory allocated by the operating system from the heap. Upon failure, the memory_allocate function returns NULL.
  • function memory_allocate (datatype, number of records of datatype) return (pointer)
  • Example: set my_pointer.self.address = memory_allocate (char, 1024);

Copyright © 2025 Robert James Bruce.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at https://www.gnu.org/licenses/fdl-1.3.html