Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,933 questions

51,870 answers

573 users

How to initialize char array with hexadecimal values in C

1 Answer

0 votes
#include <stdio.h>

int main(void) {
    unsigned char arr[32] = {0x00  ,0x01  ,0x02  ,0x03  ,0x04  ,0x05  ,0x06  ,0x07  ,0x08  ,0x09  ,0x0a  ,0x0b  ,0x0c  ,0x0d  ,0x0e  ,0x0f};
    
    for (int i = 0; i < 16; i ++)
        printf("%x - %d\n", arr[i], arr[i]);
}



/*
run:

0 - 0
1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
a - 10
b - 11
c - 12
d - 13
e - 14
f - 15

*/

 



answered Jan 21, 2021 by avibootz

Related questions

1 answer 165 views
1 answer 125 views
125 views asked Sep 18, 2021 by avibootz
1 answer 104 views
1 answer 172 views
2 answers 148 views
148 views asked May 5, 2021 by avibootz
2 answers 151 views
151 views asked May 5, 2021 by avibootz
1 answer 158 views
158 views asked Aug 23, 2016 by avibootz
...