Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:10:47+00:00 2026-06-11T09:10:47+00:00

I have an array of strings like such char *T[] = {0000, 0001, 0010,

  • 0

I have an array of strings like such

char *T[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};

When I do it like this, however, where each string is an array of unsigned chars

unsigned char *T[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};

I get the error “Initializing ‘unsigned char *’ with an expression of type ‘char[5]’ converts between pointers to integer types with different sign.” I’m guessing that means that some of the representations of “0” and “1” that are getting used are signed, but I’m not sure why/how to deal with that. I’d like to have an array of strings where each string is an array of unsigned chars rather than signed chars. Can someone help with that?

Note: this is for a HW problem, but is not the actual problem, and is just a minor step in one of many possible solutions. However, it would be good if you could help me understand it without giving me an explicit answer. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:10:49+00:00Added an answer on June 11, 2026 at 9:10 am

    C strings, one of many ways one could represent a string, consist of arrays of char terminated by a trailing char which has the null value. That’s what you get type-wise when you have “0000” in your code.

    What you want is to assign “0000” to be an array of unsigned char terminated by a trailing unsigned char which has the null value. Considering what you are starting with, you will have to cast, or perhaps represent your initial data in a manner that doesn’t require casting.

    unsigned char T[][] = { { 0x30, 0x30, 0x30, 0x30, 0x00 }, 
                   { 0x30, 0x30, 0x30, 0x31, 0x00 }, 
                   { 0x30, 0x30, 0x31, 0x30, 0x00 }, 
                   { 0x30, 0x30, 0x31, 0x31, 0x00 }, 
                   { 0x30, 0x31, 0x30, 0x30, 0x00 }, 
                   { 0x30, 0x31, 0x30, 0x31, 0x00 }, 
                   { 0x30, 0x31, 0x31, 0x30, 0x00 }, 
                   { 0x30, 0x31, 0x31, 0x31, 0x00 }, 
                   { 0x31, 0x30, 0x30, 0x30, 0x00 }, 
                   { 0x31, 0x30, 0x30, 0x31, 0x00 }, 
                   { 0x31, 0x30, 0x31, 0x30, 0x00 }, 
                   { 0x31, 0x30, 0x31, 0x31, 0x00 }, 
                   { 0x31, 0x31, 0x30, 0x30, 0x00 }, 
                   { 0x31, 0x31, 0x30, 0x31, 0x00 }, 
                   { 0x31, 0x31, 0x31, 0x30, 0x00 }, 
                   { 0x31, 0x31, 0x31, 0x31, 0x00 }
                  };
    

    The main problem I see with this approach is that it removes most of the advantage of having a C style string in the first place. With an unsigned char “string”, you have none of the standard string libraries at your disposal, so you will have to cast back to signed char string types if you want to use printf, or any other string oriented function.

    Really, you are only using two values for each possible character position “0” and “1”. Unless there is a compelling reason to do it in a string, consider an array of boolean values to reduce the chance of a string like “0hello” working it’s way into the code, or better yet if you have been introduced to bit fields, use the bits within an unsigned char as bit fields (discarding any concept that you’re dealing with strings).

    The advantages to the last technique include using less memory and the inability for the value to be other than 0 or 1; however, you will have to write a small collection of routines to translate the packed bits into something human readable.

    unsigned char[] = { 0x00, 0x01, 0x02, 0x03, 0x04,
                        0x05, 0x06, 0x07, 0x08, 0x09,
                        0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
                        0x0F };
    
    void displayChar(unsigned char value) {
      switch (value) {
        case 0x00: printf("0000"); break;
        case 0x01: printf("0001"); break;
        case 0x02: printf("0010"); break;
        case 0x03: printf("0011"); break;
    ... and so on ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of strings that are comma separated such as: Steve Jobs,12,CA
I would like to sort an array of strings (in JavaScript) such that groups
If I have an array of strings, such as string[] names = {John Doe,
An array is defined of assumed elements like I have array like String[] strArray
I have string like {param1=foo}{param2=bar}hello world! I need to extract array of tuples (paramName,
I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with
So, I have a string array of some random saying and the like, but
How do i explode this string '||25||34||73||94||116||128' i need to have a array like
I have string that look like Array that fetched from other webservice like this
I have defined an array like so : var myArray = {myNewArray: ['string1' ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.