Union, bitfield, typedef, enum union nama_u{ ------ }; union nama_u{ ------ struct nama_s byte; ------ }; enum{ }; Tipedef var BYTE.

Slides:



Advertisements
Similar presentations
Complete Structure class Date {class Date { private :private : // private data and functions// private data and functions public :public : // public data.
Advertisements

C Language Reference The C language is a general-purpose programming language known for its efficiency, economy, and portability. While these characteristics.
For(int i = 1; i
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Class 15 - Overhead 11Object Oriented Programming Using C #define t_circle 1 #define t_rectangle 2 struct circle_shape {short type; double x,y; double.
File and I/O system calls int open(const char* path, int flags, mode_t modes) int creat(const char *path, mode_t mode) ssize_t read(int fd, void *buf,
Unions The storage referenced by a union variable can hold data of different types subject to the restriction that at any one time, the storage holds data.
1 Class Vehicle #include #define N 10../.. 2 Class Vehicle class vehicle { public: float speed; char colour[N+1]; char make[N+1];
Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT}; Day today; today = WED; if (today == FRI) cout
C++ Basics Variables, Identifiers, Assignments, Input/Output.
Dale/Weems/Headington
Passing arguments by value void func (int x) { x = 4; }... int a = 10;... func(a); cout
Template MetaProgramming in C++ Giuseppe Attardi Università di Pisa.
C Language Summary HTML version. I/O Data Types Expressions Functions Loops and Decisions Preprocessor Statements.
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
Programming C/C++ on Eclipe Trình bày : Ths HungNM C/C++ Training.
Variables and constants Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences.
Data Type. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common.
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
 Review structures  Program to demonstrate a structure containing a pointer.
ACE Address Configuration Executive. Why ACE? ACE provides access to several address resolution protocols under a single API ACE is the only API available.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Unions and Bitfields Gabriel Hugh Elkaim Spring 2013.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
Structures and Unions in C Alan L. Cox
UNION UNIT -II. Unions A union is another compound datatype like a structure. So what is the properties of structure? Eg: Union exam { int roll_no; Char.
Structures and Union. Review bitwise operations –you need them for performance in terms of space and time –shifts are equivalent to arithmetics enumeration.
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
Structure A collection of values (members) struct date{ int day; char month[10]; int year; }; Declare a structure variable struct date today; struct struct_name.
Presented by: © 2015 Jacob Beningo All Rights Reserved Writing Portable and Robust Firmware in C September 2, 2015 Jacob Beningo, CSDP Class 3: Uart Driver.
Data Types (1) 1 Programming Languages – Principles and Practice by Kenneth C Louden.
NESTED CLASS. Apa itu nested class ? Nested class is a class defined inside a class, that can be used within the scope of the class in which it is defined.
Java Programming Language Lecture27- An Introduction.
C++ Lesson 1.
Asst.Prof.Dr. Tayfun ÖZGÜR
Ex-1 #include <stdio.h> struct sample { int a=0; char b='A';
The C++ Data Types Fundamental Data Types
Control Statements in C
Structures, Unions, Enumerations
LESSON 3 IO, Variables and Operators
مبانی کامپیوتر و برنامه سازی
Reserved Words.
DATA HANDLING.
IBP Client APIs Storage Management IBP_allocate , IBP_manage
Structures and Union.
פרטים נוספים בסילבוס של הקורס
אבני היסוד של תוכנית ב- C++
אבני היסוד של תוכנית ב- C++
הרצאה 03 אבני היסוד של תוכנית ב- C
פרטים נוספים בסילבוס של הקורס
Windows Programming Lecture 04
Govt. Polytechnic,Dhangar
CSE 100 Data Types Declarations Displays.
JavaScript Reserved Words
Chapter 1: Introduction to Data Structures(8M)
Variables in C Declaring , Naming, and Using Variables.
Structures and Union.
C Structures, Unions, Bit Manipulations and Enumerations
Function Overloading.
Programming Language C Language.
Chapter 6 Part 1.
Structures and Union.
Displaying Memory/Files
CSCE 206 Lab Structured Programming in C
C++ New Types.
C++ Parse Analysis Introduction
Default argument Kei Hasegawa.
Presentation transcript:

union, bitfield, typedef, enum union nama_u{ }; union nama_u{ struct nama_s byte; }; enum{ }; Tipedef var BYTE

Contoh 1 #include void main() { union { unsigned int di; unsigned char dc[2]; }bil_x; bil_x. di=321; cout<<bil_x.di<<endl;//321 cout<<bil_x.dc[0]<<endl;//32 cout<<bil_x.dc[1]<<endl;//1 }

contoh2 #include void main() { Struct info_byte { unsigned bit0 :1; unsigned bit1 :1; unsigned bit2 :1; unsigned bit3 :1; unsigned bit4 :1; unsigned bit5 :1; unsigned bit6 :1; unsigned bit7 :1; }; union { unsigned char karakter; struct info_byte byte; }ascii; ascii.karakter = ‘A’; cout<<ascii.karakter<<endl;//65 cout<<ascii.byte.bit7, ascii.byte.bit6, ascii.byte.bit5, ascii.byte.bit4, ascii.byte.bit3, ascii.byte.bit2, ascii.byte.bit1, ascii.byte.bit0 <<endl;// }

#include void main() { enum manusia { pria, wanita}; enum manusia jenis_k; jenis_k=pria; cout<<jenis_k<<endl;//0 jenis_k=wanita; cout<<jenis_k<<endl;//1 }

#include typedef unsigned char BYTE; BYTE beri_nilai(void); void main() { BYTE kode; Kode=beri_nilai(); cout<<“Kode =“<<kode<<endl;//56 } BYTE beri_nilai(void) { return(256);}.