Declaring an array of hexadecimals

Dec 26, 2013 at 3:48am
I'm making a flash card type console application using visual studios 2013. The flash cards contain character that I can display using unicode. So far I am looking at about 200 characters across 2 unicode blocks which I don't want to hard code into my arrays. I thought of initializing my arrays using a loop. The only problem is I don't know how to add in hexadecimal. So is there a way to initialize my array without having to input 200 values my self? Also is hexadecimal addition possible without me having to write a function for it?
Last edited on Dec 26, 2013 at 6:02pm
Dec 26, 2013 at 4:19am
@wahhaj

Here's a little demo that I believe will answer your questions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Using Hex.cpp : main project file.

#include <iostream>

int main()
{
      char hex[200];
      char start = '\x30', end = '\x10';
      for(int x=0;x<200;x++)
	 hex[x] = start+x;
     // Increases hex value in array

      for(int x=0;x<200;x++)
	 std::cout << hex[x] << "  ";

     start+=end; //adding both char values
     std::cout << std::endl << start << std::endl;
    return 0;
}
Dec 26, 2013 at 6:13pm
This makes sense. From what I make sense of this hexadecimal addition is just like regular addition. The computer knows what it's doing. Just one question, should I be worried about Hex.cpp at line 1?
Dec 26, 2013 at 10:22pm
@wahhaj

Line one is nothing but a comment. That was just the name I gave the program when I started up Microsoft Visual Express, to write the program, then the C++ program wrote that line when it created the body of the program.
Topic archived. No new replies allowed.