#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <unistd.h>

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>

#define SHM_KEY 1234

using namespace std;

void *attach_shared_memory(size_t& shm_bytes){
	int shmid=shmget(SHM_KEY,1,0666);
	if (shmid==-1) {
		cout << "Attach memory failed " << endl;
		_exit(1);
	}
	void *base=shmat(shmid,NULL,0);
	return base;
}

int main(void) {
	size_t l=10000;
	size_t n = 640;
	
	size_t shm_bytes=l*n*n*sizeof(uint8_t);
	void *base=attach_shared_memory(shm_bytes);
	uint8_t *a = (uint8_t *)base;
	for(int i=0; i<n; i++){
		cout << (unsigned int)a[i] << " " ;
	}
	cout << endl;
}
