Skip to content

Instantly share code, notes, and snippets.

@eiri
Created April 19, 2016 01:21
Show Gist options
  • Save eiri/83c3a70ac15c6eb54cf707d7cf8514d4 to your computer and use it in GitHub Desktop.
Save eiri/83c3a70ac15c6eb54cf707d7cf8514d4 to your computer and use it in GitHub Desktop.
Write and read in ram file in erlang
-module(mardear).
-export([readram/0]).
readram() ->
{ok, Fd} = file:open([], [ram, write, read]),
IoData = io_lib:format("~s", [[$r, $a, $m]]),
ok = file:write(Fd, IoData),
{ok, Str} = file:pread(Fd, 0, 8192),
ok = file:close(Fd),
Str.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment