Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
FILE *file;
size_t len=0;
char *lines;
assert(file=fopen(f,"rb"));
assert(lines=malloc(sizeof(char)));
while(!feof(file))
{
assert(lines=realloc(lines,(len+0x1000)*sizeof(char)));
len+=fread(lines,1,0x1000,file);
}
assert(lines=realloc(lines,len*sizeof(char)));
int err = 0;
int fd = 0;
void * ptr = NULL;
struct stat st;
if ((fd = open (f, O_RDONLY))
&& (err = fstat (fd, &st)) == 0
&& (ptr = mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) != -1) {
const char * lines = ptr;
puts (lines);
munmap (ptr, st.st_size);
close (fd);
}
(def lines (slurp f))
lines = File.read!(f)
{ok, Lines} = file:read_file(F).
program p
character(len=:),allocatable :: s
open(unit=10,file='myfile',access='stream')
inquire(10,size=i)
allocate(character(len=i) :: s)
read(10)(s(j:j),j=1,i)
write(*,*)s
end program p
do lines <- readFile f; putStr lines
(with-open-file (stream f)
(uiop:slurp-stream-string stream))
(defvar *lines*
(with-open-file (stream f)
(let ((contents (make-string (file-length stream))))
(read-sequence contents stream)
:return contents)))
lines = io.input(f):read('a')
$lines = file_get_contents('f');
if ($lines === false) {
// handle error...
}
open my $fh, '<', $f;
my $lines = do { local $/; <$fh> };
close $fh;
with open(f) as fo:
lines = fo.read()
lines = open(f).read()
lines = File.read(f)
| lines |
lines := f asFilename readStream upToEnd.
Dim lines = IO.File.ReadAllText(f)