User Tools

Site Tools


courses:programming:topic8

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
courses:programming:topic8 [2016/10/27 12:20]
kkv
courses:programming:topic8 [2022/12/10 09:08] (current)
Line 8: Line 8:
   * рекурсия и циклы   * рекурсия и циклы
  
-  #include <​stdio.h>​ +== Примеры с лекции ==
-  #include <​string.h>​+
  
-  ​struct TEST { +  ​* https://github.com/​moevm/​pr1-samples/​blob/​master/​2016-11-03-20-58.18/main.cpp
- +
-    char name[9]; +
-    int  age; +
- +
-  } _test; +
- +
-  union TESTU  +
-  { +
-    char name[9]; +
-    ​//int  age; +
-    char age; +
-  } test; +
- +
-  int main() +
-  { +
-    strcpy(test.name, "​Vasya"​);​ +
-    test.age = 86; +
- +
-    int size = (int)sizeof(test);​ +
-    printf("​size %d\n",​size);​ +
- +
-    printf("​%p %p\n", &​test.name,​ &​test.age);​ +
- +
-    printf("​%s is %d\n",​test.name,​ test.age);​ +
- +
-    char *ptr = (char*)&​test;​ +
- +
-    for(int i=0;​i<​size;​i++) +
-    { +
-      printf("​[%d,​%c,​0x%X] ",​*ptr,​*ptr,​*ptr);​ +
-      ptr++; +
-    } +
- +
-    printf("​\nage = %d or 0x%X\n",​test.age,​test.age); +
-  }+
courses/programming/topic8.1477570803.txt.gz · Last modified: 2022/12/10 09:08 (external edit)