Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. int main ()
  2. {
  3. /* The file descriptor. */
  4. int fd;
  5. /* Information about the file. */
  6. struct stat s;
  7. int status;
  8. size_t size;
  9. /* The file name to open. */
  10. const char * file_name = "file.dem";
  11. /* The memory-mapped thing itself. */
  12. const char * mapped;
  13. int i;
  14.  
  15. /* Open the file for reading. */
  16. fd = open ("file.dem", O_RDONLY);
  17. check (fd < 0, "open %s failed: %s", file_name, strerror (errno));
  18.  
  19. /* Get the size of the file. */
  20. status = fstat (fd, & s);
  21. check (status < 0, "stat %s failed: %s", file_name, strerror (errno));
  22. size = s.st_size;
  23.  
  24. /* Memory-map the file. */
  25. mapped = mmap (0, size, PROT_READ, MAP_PRIVATE, fd, 0);
  26. check (mapped == MAP_FAILED, "mmap %s failed: %s",
  27. file_name, strerror (errno));
  28.  
  29. /* Now do something with the information. */
  30. for (i = 0; i < size; i++) {
  31. // print longitude, latitude, elevation values
  32. }
  33. printf("Total iteration : %d", i);
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement