Skip to content

Instantly share code, notes, and snippets.

@bmander
Created August 8, 2011 21:26
Show Gist options
  • Save bmander/1132795 to your computer and use it in GitHub Desktop.
Save bmander/1132795 to your computer and use it in GitHub Desktop.
a trivial mmap example
abcdefghijklmnopqrstuvwxyz
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
int main() {
int fd = open( "data", O_RDONLY );
char* target;
target = mmap( NULL, 10, PROT_READ, MAP_SHARED, fd, 0 );
int i;
for(i=0; i<10; i++) {
putchar( target[i] );
}
close( fd );
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment