Pagini recente » Cod sursa (job #2303544) | Cod sursa (job #1152212) | Cod sursa (job #337848) | Cod sursa (job #2058376) | Cod sursa (job #2473674)
// Copyright 2019 Ciobanu Bogdan-Calin
// [email protected]
#include <iostream>
//#include "./Parser.h"
//#include "./Writer.h"
#include <cstdio>
#include <cstring>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd = open("adunare.out", O_RDWR | O_CREAT, (mode_t)0600);
const char* text = "2\n";
size_t textsize = strlen(text) + 1;
lseek(fd, textsize-1, SEEK_SET);
write(fd, "", 1);
char* map = (char*)mmap(0, textsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
memcpy(map, text, strlen(text));
msync(map, textsize, MS_SYNC);
munmap(map, textsize);
close(fd);
return 0;
}
/*
int main() {
mapping_writer t("test.txt");
mapping_parser f("test.in");
int x = 10;
uint8_t y = 100;
uint64_t z = 10000000000022;
bool m = false;
int o = 0;
f >> x;
f >> y;
t << x << "\n";
t << y << "\n";
t << z << "\n";
t << m << "\n";
t << o << "\n";
return 0;
}
*/