Thread: signed char array to unsign char array.

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    58

    signed char array to unsign char array.

    Hi everyone


    Anyone know how to convert and pass value from a signed char array to a unsigned array ?

  2. #2
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    None needed. Did you even try?

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    58
    Hi onion Knight,
    Actually I need to convert it because I had a function that take in unsigned char. Therefore when I need to use it with my signed parameter, it will always gave me a error message. That is why I wonder is there a way to convert it to unsigned value.

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    int mf(unsigned char* inp);
    
    signed char arr[] = "Test";
    mf((unsigned char*)arr);
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    It should just give a warning. But like vart demonstrates, you can just type cast it.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    58
    Thanks alot vart ..

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. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  3. Creating 2D arrays on heap
    By sundeeptuteja in forum C++ Programming
    Replies: 6
    Last Post: 08-16-2002, 11:44 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM