简体   繁体   中英

Decoding an array

So, I'm trying to decode this array into a string of text (ASCII) I'm not entirely sure how to go about this and I have no experience with C, but I do have access to a text editor or a terminal. Is there any tools i can use on a UNIX-based platform (GNU)?

char name[] = { 0x64, 0160, (114-63), (064+03), 0x00 };

Thank you!

如果要为每个名称索引在循环中使用printf("%c",name[i])打印此序列,它将自动将十六进制和八进制表示形式转换为十进制并打印关联的ASCII符号

Of course, the easiest way would be to compile and run the program. But, that's not really the point of this kind of code exercise. Once you recognize the trick that these are just different base representations of numbers, then you real should go through the task of calculating the numbers and looking them up in the ascii table that's almost certainly in the back of the textbook or available on the same tutorial site.

Remember the fundamental theorem of arithmetic:

12345 = 1 *10^4 + 2 *10^3 + 3 * 10^2 + 4 * 10^1 + 5 * 10^0
0xABC = A * 16^2 + B * 16^1 + C * 16^0

You can also investigate these with a (sufficiently powerful) text editor. You'll need to do the addition yourself, but in vim you hit ctrl-V and then the number followed by whitespace (which you can then delete).

If the integral values correspond to ascii you could simply cast them to characters. Characters are actually uint8 in C. So if you have integers that correspond to some ascii you can simply the compiler to treat them as such.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM