Thread: bit field on c

  1. #1
    Registered User
    Join Date
    Apr 2018
    Posts
    6

    Question bit field on c

    hello ,
    i have project to do and i need to build project the project need to be
    with bit field with 14 bit
    in the end its need to be translate to assembly language
    i still dont know how to do this but i need to make 8 place with 14 bit
    Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,325
    The syntax is simple enough, if you understand struct.
    Code:
    struct foo {
      unsigned int myfield:14;
    };
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Location
    Namib desert
    Posts
    90
    FYI, the sizeof() a struct foo shows you the size of an unsigned int ( which on my system is 4 (bytes)).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is bit field in C?
    By camateur in forum C Programming
    Replies: 4
    Last Post: 02-15-2016, 01:58 PM
  2. need help in bit field
    By lovesunset21 in forum C Programming
    Replies: 27
    Last Post: 10-31-2010, 02:52 AM
  3. Replies: 2
    Last Post: 06-07-2009, 08:49 AM
  4. Get data from a .txt file field by field...
    By IndioDoido in forum C Programming
    Replies: 5
    Last Post: 10-19-2007, 06:07 PM
  5. bit field
    By sufthingol in forum C++ Programming
    Replies: 6
    Last Post: 03-22-2005, 03:59 PM

Tags for this Thread