« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Examples

Usage

var x = new(File, $S("test.bin"), $S("wb"));
char* data = "hello";
swrite(x, data, strlen(data));
sclose(x);

Formatted Printing

var x = $(File, NULL);
sopen(x, $S("test.txt"), $S("w"));
print_to(x, 0, "%$ is %$ ", $S("Dan"), $I(23));
print_to(x, 0, "%$ is %$ ", $S("Chess"), $I(24));
sclose(x);

Automatic Closing

with(f in new(File, $S("test.txt"), $S("r"))) {
  var k = new(String); resize(k, 100);
  var v = new(Int, $I(0));
  foreach (i in range($I(2))) {
    scan_from(f, 0, "%$ is %$ ", k, v);
    show(k); show(v);
  }
}

File


Operating System File

The File type is a wrapper of the native C FILE type representing a file in the operating system.

Definition

struct File {
  FILE* file;
};

Derives

Implements

  • Docname brief description definition
  • Formatformat_to format_from
  • Newnew del construct destruct
  • Startwith start stop join running
  • Streamsopen sclose sseek stell sflush seof sread swrite

Back