signed char array to unsign char array.

This is a discussion on signed char array to unsign char array. within the C Programming forums, part of the General Programming Boards category; Hi everyone Anyone know how to convert and pass value from a signed char array to a unsigned 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
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    Code:
    int mf(unsigned char* inp);
    
    signed char arr[] = "Test";
    mf((unsigned char*)arr);
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    2,009
    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

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