Maybe something like
int fbfd = 0;
// Open the framebuffer for reading and writing
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd) {
printf("Error: cannot open framebuffer device.\n");
exit(1);
}
// Map the framebuffer to memory
unsigned int * fbp = (unsigned int *)mmap(0, XRES*YRES*4, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
then fbp is a pointer to the framebuffer memory
EDIT: or just set fbfd to the physical address?