Split up an Array

This is a discussion on Split up an Array within the C Programming forums, part of the General Programming Boards category; Hello, Im doing a project that i need to split up the first 6 bytes of an array individually. The ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    3

    Split up an Array

    Hello,
    Im doing a project that i need to split up the first 6 bytes of an array individually. The first 3 bytes needs to be in Binary and the remaining 3 need to be in HEx. Any ideas , as i've only started learning C today!
    Shane

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    What is the type of the array?
    What is the contents?
    What do you mean by split?

    All data in computer - is binary, when talking about hex - talking about representation of the data. So how do you want to represent (print out) your data?

    start with some code
    Code:
    int main(void)
    {
       return 0;
    }
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    3
    honestly i don't know , but attached is the array
    could u point me in the right dirtection



    I need 128 to 152 to be sperated individually if that makes sence
    Attached Images Attached Images  
    Last edited by shanem; 01-22-2009 at 09:22 AM.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Quote Originally Posted by shanem View Post
    honestly i don't know , but attached is the array
    could u point me in the right dirtection...
    I need 128 to 152 to be sperated individually if that makes sence
    No it still doesn't make any sense. Everything inside the machine is stored as binary so you can't separate them into binary and hex except at the presentation layer.

  5. #5
    Banned
    Join Date
    Jan 2009
    Posts
    30
    ....
    Attached Images Attached Images  

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    3
    Ok i'll try to be a bit more clear, The 128 value corresponds to 1000000

    On my data sheet for this represents "Slave is in sync mode"
    If the value comes in at 46 -101110 for example " Slave is in sync mode , freeze off ,slave is locked, watch dog on....) etc.

    The second third fourth fifth and sixth bytes needs to be represented the same way.

    So what i need to do is split up the first 6 bytes on the array, get there binary values and match that to my reference guide and display these messages in a text box!
    Any takers,

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    128 in binary is 10000000.
    So, what, you have a list like this:
    Code:
    #define SYNC_MODE 64
    #define FREEZE 32
    #define LOCKED 16
    #define WATCHDOG 8
    and you want to know whether that particular bit is set? So why not do bitwise and?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  2. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Array Program
    By emmx in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 12:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21