Results 1 to 2 of 2
Hello everyone
I would to ask anyone hear has experiance on how to standardize data type of our own creation. This is the scenario.
As we know, in C we ...
- 02-17-2009 #1Just Joined!
- Join Date
- Dec 2007
- Posts
- 19
Standardizing Data Type in C
Hello everyone
I would to ask anyone hear has experiance on how to standardize data type of our own creation. This is the scenario.
As we know, in C we have data type of int, char, unsigned char..etc but we dont have a byte data type. But then, I am really aware that char is actually represent directly as BYTE. So, now I would like to standardize the BYTE as my own data type. If we define as typedef unsigned char byte, that should solve the problem. But, when we have a SHA1 encryption, comparing when the program accepts a string, the value of the string that has been hash is different with the value if we convert it to byte. This is because the string is from the keyboard, which mainly represents as ASCII character. I have test this thing and mainly both of the hash values is different. So what I want to do, is rather than declaring as char/unsigned char, i would like to declare it as BYTE where the byte is actually purely BYTE (RAW BYTE). What I have done now is when user enter string from the keyboard, the string is converted to BYTE which represents a hex by calling a function of that conversion which I done it myself. So now, rather I wanna call a function, I really love to make it standardize, which mean I dont need to call the function, when i declare BYTE, it will convert directly to the data that I want. It goes the same with int or char. How does the compiler recognize it as int? There must be a way that the int data type must follow a certain procedure so that the compiler understood int. Does anyone have any idea or any comment about my understanding. If Im wrong, pls correct me. Thanks.
- 02-17-2009 #2
I'm not sure if you are talking about a new type or an existing type with a restricted set values...
If you check C data types you will see the types correspond not only to areas of memory(1 bytes, 2 bytes, 4 bytes...etc) but opcodes to work on these memory areas...
Maybe if you gave us an example of your raw byte type....


Reply With Quote