Exemplo n.º 1
0
int main(void)
{
   Views box = {{true, YELLOW, true, GREEN, DASHED}};
   char bin_str[CHAR_BIT*sizeof(unsigned int)+1];

   puts("Original box settings");
   show_settings(&box.st_view);

   puts("\nBox settings using unsigned int view:");
   show_settings1(box.us_view);
   printf("bits are %s\n", itobs(box.us_view, bin_str));

   box.us_view &= ~FILL_MASK;  // Clear fill bits
   box.us_view |= (FILL_BLUE|FILL_GREEN);
   box.us_view ^= OPAQUE;      // Toogle opacity
   box.us_view |= BORDER_RED;  // wrong approach
   box.us_view &= ~STYLE_MASK; // Clear style bits
   box.us_view |= B_DOTTED;    

   puts("\nModified box settings:");
   show_settings(&box.st_view);
   puts("\nBox settings using unsigned int view");
   show_settings1(box.us_view);
   printf("bits are %s\n", itobs(box.us_view, bin_str));

   return 0;
}
Exemplo n.º 2
0
int main(void) {
    /* create Views object, initialize struct box view */
    union Views box = {{YES, YELLOW , YES, GREEN, DASHED}};
    char bin_str[8 * sizeof(unsigned int) + 1];
    printf("Original box settings:\n");
    show_settings(&box.st_view);
    printf("\nBox settings using unsigned int view:\n");
    show_settings1(box.ui_view);
    printf("bits are %s\n",
           itobs(box.ui_view, bin_str));
    box.ui_view &= ~FILL_MASK;          /* clear fill bits */
    box.ui_view |= (FILL_BLUE | FILL_GREEN); /* reset fill */
    box.ui_view ^= OPAQUE;               /* toggle opacity */
    box.ui_view |= BORDER_RED;           /* wrong approach */
    box.ui_view &= ~STYLE_MASK;        /* clear style bits */
    box.ui_view |= B_DOTTED;         /* set style to dotted*/
    printf("\nModified box settings:\n");
    show_settings(&box.st_view);
    printf("\nBox settings using unsigned int view:\n");
    show_settings1(box.ui_view);
    printf("bits are %s\n",
           itobs(box.ui_view, bin_str));
    return 0;
}