Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Bitex
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//gcc 7.4.0 //Bitex: bit field example //this code is created by Rezaul Hoque on April 01,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <stdio.h> struct bitex{ unsigned int a:3; unsigned int b:3; unsigned int c: 1; unsigned d:1; unsigned e:1; }; void display(struct bitex); void display(struct bitex bit){ printf("a: %d\n",bit.a); printf("b: %d\n",bit.b); printf("c: %d\n",bit.c); if(bit.d) printf("d is assigned a nonzero value.\n"); else printf("d is assigned zero.\n"); if(bit.e) printf("e is assigned a nonzero value.\n"); else printf("e is assigned zero.\n"); } int main(void) { struct bitex bit; bit.a=3; bit.b=2; bit.c=1; bit.d=1; bit.e=0; display(bit); return 0; }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.12 sec, absolute running time: 0.15 sec, cpu time: 0.01 sec, memory peak: 5 Mb, absolute service time: 0,34 sec
edit mode
|
history
|
discussion
a: 3 b: 2 c: 1 d is assigned a nonzero value. e is assigned zero.