Enviado em 01/06/2013 - 12:05h
#include <stdio.h>
#include <stdlib.h>
typedef struct OBJECT OBJECT;
struct OBJECT
{
int id;
int flags;
};
OBJECT *win;
void create (void)
{
win = (OBJECT*) malloc (sizeof(OBJECT));
if (!win)
{
printf ("xi, ferrou ... sem memoria ;)\n");
exit (-1);
}
win->id = 200;
win->flags = 300;
}
void change_id_flags (OBJECT *o)
{
int *p;
p = (int*)o; // get id
*p = 2222; // set id
p++; // change to flags ... get flags
*p = 3333; // set flags
}
int main (void)
{
create ();
// ORIG: 200, 300
//
printf ("\nORIG OBJECT->id: %d\n", win->id);
printf ("ORIG OBJECT->flags: %d\n\n", win->flags);
printf ("------- CHANGING -------\n\n");
change_id_flags (win);
// CHANGED: 2222, 3333
//
printf ("NOW OBJECT->id: %d\n", win->id);
printf ("NOW OBJECT->flags: %d\n", win->flags);
return 0;
}
Como escolher o melhor escalonador de CPU para melhorar o desempenho da máquina
Curiosidade sobre DOOM Guy e Isabelle de Animal Crossing
Inicializando servidor Ubuntu na AWS e rodando apache em Container
Instalando TeamViewer no Debian 12
Conheça o Octopi, outro frontend para o Pacman com acesso ao AUR (Arch Linux e derivados)
Terminal transparente no Debian 12 com interface i3wm usando Xfce4-Terminal e Compton
Eu estou com problemas para usar o QBASIC no Dosbox X (4)