Char Hexa Conversion for socket raw!HELP ME PLEASE!

This is a discussion on Char Hexa Conversion for socket raw!HELP ME PLEASE! within the C Programming forums, part of the General Programming Boards category; Hello! I have a little problem. I want to send with socket raw some message to a server from a ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    4

    Char Hexa Conversion for socket raw!HELP ME PLEASE!

    Hello!
    I have a little problem.
    I want to send with socket raw some message to a server from a client.
    The Hardware Address of then client is given as main argv.
    Now I must set these fields:
    unsigned char sll_addr[8];
    Example:
    if the Hardware Address is "01:02:03:04:05:FF" I must set:
    sll_addr[0]=0x01;
    sll_addr[1]=0x02;
    sll_addr[2]=0x03;
    sll_addr[3]=0x04;
    sll_addr[4]=0x05;
    sll_addr[5]=0xFF;

    Now how do I make a function that has as parameter a string like "01:02:03:04:05:FF" and set sll_addr?
    PLEASE HELP ME!
    THANK YOU!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    Say
    Code:
    sscanf( argv[1], "%x:%x:", &sll_addr[0], sll_addr[1] );
    I'm sure you can add 4 more %x to that
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Conversion Char To Char * Problem
    By ltanusaputra in forum Windows Programming
    Replies: 3
    Last Post: 03-01-2008, 01:06 PM
  3. Fixing Errors
    By brietje698 in forum Networking/Device Communication
    Replies: 9
    Last Post: 12-10-2007, 10:17 PM
  4. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 04:42 PM
  5. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 10:31 PM

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