summaryrefslogtreecommitdiff
path: root/Practical_C_Programming/Chapter_12_1.ipynb
blob: 090a4ee13073f681461e8f7901dc90d5adb2c318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
 "metadata": {
  "name": "",
  "signature": "sha256:184261c50791da479b656a01719125426370a323ab51da034b4dc57d574572c3"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12: Advanced types"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 12.1, Page number: 212"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Union declaration\n",
      "from ctypes import *\n",
      "class value (Union) :\n",
      "   _fields_ = [(\"i_value\", c_int),\n",
      "               (\"f_value\", c_float)]\n",
      "\n",
      "# Calculation and result\n",
      "data = value (3, 5.0)\n",
      "print (data.i_value, data.f_value)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(1084227584, 5.0)\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}