User Tools

Site Tools


courses:programming:topic8

Differences

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

Link to this comparison view

courses:programming:topic8 [2016/10/27 12:19]
kkv
courses:programming:topic8 [2022/12/10 09:08]
Line 1: Line 1:
-=== Лекция 8 === 
  
-  * опрос 
-  * экзамены 
-  * доп занятия 
-  * контрольная 
-  * объединения 
-  * рекурсия и циклы 
- 
-  #include <​stdio.h>​ 
-#include <​string.h>​ 
- 
-struct TEST { 
- 
-  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.txt · Last modified: 2022/12/10 09:08 (external edit)