Skip to content
Snippets Groups Projects
Select Git revision
  • 410f2578fa2695a81acaa9e69b1d3b08d9af3bc7
  • master default protected
  • v3-modify-mail
  • snyk-fix-207483a1e839c807f95a55077e86527d
  • translations_3b5aa4f3c755059914cfa23d7d2edcde_ru
  • translations_6e4a5e377a3e50f17e6402264fdbfcc6_ru
  • translations_3b5aa4f3c755059914cfa23d7d2edcde_fa_IR
  • translations_en-yml--master_fa_IR
  • snyk-fix-7d634f2eb65555f41bf06d6af930e812
  • translations_en-yml--master_ar
  • translations_3b5aa4f3c755059914cfa23d7d2edcde_el
  • jfederico-patch-1
  • v2
  • v3
  • v1
  • release-3.1.0.2
  • release-3.1.0.1
  • release-3.1.0
  • release-2.14.8.4
  • release-3.0.9.1
  • release-3.0.9
  • release-3.0.8.1
  • release-2.14.8.3
  • release-3.0.8
  • release-3.0.7.1
  • release-2.14.8.2
  • release-3.0.7
  • release-3.0.6.1
  • release-3.0.6
  • release-3.0.5.4
  • release-3.0.5.3
  • release-2.14.8.1
  • release-3.0.5.2
  • release-3.0.5.1
  • release-3.0.5
35 results

README.md

Blame
  • aufgabe-2b.c NaN GiB
    #include <stdio.h>
    
    #define ANIMAL     0
    #define WITH_WINGS 1
    #define WITH_LEGS  2
    
    typedef struct animal
    {
      int type;
      char *name;
    } animal;
    
    typedef struct with_wings
    {
      int wings;
    } with_wings;
    
    typedef struct with_legs
    {
      int legs;
    } with_legs;
    
    int main (void)
    {
      animal *a[2];
    
      animal duck;
      a[0] = &duck;
      a[0]->type = WITH_WINGS;
      a[0]->name = "duck";
      ((with_wings *) a[0])->wings = 2;
    
      animal cow;
      a[1] = &cow;
      a[1]->type = WITH_LEGS;
      a[1]->name = "cow";
      ((with_legs *) a[1])->legs = 4;
    
      for (int i = 0; i < 2; i++)
        if (a[i]->type == WITH_LEGS)
          printf ("A %s has %d legs.\n", a[i]->name,
                  ((with_legs *) a[i])-> legs);
        else if (a[i]->type == WITH_WINGS)
          printf ("A %s has %d wings.\n", a[i]->name,
                  ((with_wings *) a[i])-> wings);
        else
          printf ("Error in animal: %s\n", a[i]->name);
    
      return 0;
    }