RagHaven
RagHaven

Reputation: 4337

mmap in C for textfiles

Is it possible to use mmap in C for reading textfiles ? I know its possible with binary files. But when I try to read an entire textfile I seem to be having some problems.

Upvotes: 0

Views: 156

Answers (2)

gulyan
gulyan

Reputation: 662

You can use mmap on any file.

You should elaborate on your problems.

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318518

Yes, that works of course - "text files" are just a subset of "binary files" anyway.

However, don't expect a trailing \0 so you cannot use any string functions since they require NUL-terminated strings.

Upvotes: 2

Related Questions