Sponsored Content
Top Forums Programming After converting the hexstr to Hex and storing the Hex in a char* Post 302342458 by Gunther on Sunday 9th of August 2009 10:18:08 PM
Old 08-09-2009
> convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ','
I'm not really sure what you're trying to accomplish with that. A C-string in hex format is *one* printable representation of a number. In the computer's storage there is no such thing as hex format, it's just bits and bytes.

So, without reading your code, the only sane thing regarding number conversion is to switch between representations. I would suggest something like this:
> snprintf(string, sizeof(string)-1, "%x", (unsigned int)n)
 

10 More Discussions You Might Find Interesting

1. Programming

converting hex to ascii

Hi everyone! I was wondering if anyone knows how to change hex code back into ascii. when i process a form: " / " turn to " %2F " " @ " turns to " %40 " " ' " turns to " %27 " " ( " turns to " %28 " " ) " turns to " %29 " this is my code so far: order.txt thanks, primal p.s.... (1 Reply)
Discussion started by: primal
1 Replies

2. Shell Programming and Scripting

converting hex to dec

Hi Experts, I have a file called "hex" which contains info like below How do i convert everything in this file to decimal value? Please advice. Thanks (4 Replies)
Discussion started by: aismann
4 Replies

3. UNIX for Dummies Questions & Answers

ANSI C, char to hex conversion

Hi, I have a char buf,ch; and the buf is filled with the result from MySQL server which I get like this numbytes = recv(sock, buf, 1024, 0));I have the followingcode to display the results printf("received %ld bytes:\n",numbytes); for(c=0;c<numbytes;c++){ ch = (char)buf; ... (2 Replies)
Discussion started by: alikims
2 Replies

4. UNIX for Advanced & Expert Users

converting openssl hex dump or PEM format to integer array

Hello. I'm working on a project that involves creating public/private keys server-side using openssl and using the public key in a Javascript application to encrypt sensitive data in form fields before transmission to the server. Using an SSL https server connection was not an option in this... (1 Reply)
Discussion started by: jhopper
1 Replies

5. Shell Programming and Scripting

Converting hex value 7C (for pipe) to CRLF in Unix

I am trying to convert a txt file that includes one long string of data. The lines are separated with hex value 7C (for pipe). I am trying to process this file using SQR (Peoplesoft) so I thought the easiest thing to do would be to replace the eol char with a CRLF in unix so I can just... (4 Replies)
Discussion started by: sfedak
4 Replies

6. Programming

how to use hex escape char with string in C?

I want it to ouput "abcd", but it dosen't. 1 #include<stdio.h> 2 int main() 3 { 4 printf("a\x62cd"); 5 } 6 gcc alarm.c -o alarm alarm.c: In function 'main': alarm.c:4:9: warning: hex escape sequence out of range It seems that the complier joint "cd" as part of... (8 Replies)
Discussion started by: vistastar
8 Replies

7. Programming

What is the difference between ios::hex and std::hex?

Hi, Is there really a difference between these two, std::hex and ios::hex?? I stumbled upon reading a line, "std::ios::hex is a bitmask (8 on gcc) and works with setf(). std::hex is the operator". Is this true? Thanks (0 Replies)
Discussion started by: royalibrahim
0 Replies

8. Shell Programming and Scripting

Converting hex to ascii/decimal

I am writing a bash script to do some parsing on a log and I am running into a problem when it comes to converting only certain sections of the file from hex to ascii or hex to decimal. Data Example: The hex values after Hardware and SW Version I need to convert from Hex to ASCII and the... (16 Replies)
Discussion started by: Shiftkey
16 Replies

9. Shell Programming and Scripting

Converting parts of a string to "Hex"

Hi Guys, writing a small shell script, i need to convert parts of a string to "Hex". The problem is that it is not the full string that needs to be converted. I think it's best to show an example: $astring = "xxxxxx ABC+10+##########+DEF xxxx" This is only an example to show how the... (9 Replies)
Discussion started by: HansHansen
9 Replies

10. Shell Programming and Scripting

Converting decimal to hex

How to convert decimal value to hex and than take 1st digits as variable sample data 84844294,5,6 51291736,2,3 84844294,5,6 51291736,2,3 i can use {printf "%x,%d\n",$1,$2} but than i want to filter base on 1st hex digit 1st recrd (1 Reply)
Discussion started by: before4
1 Replies
Hex-a-hop(6)															      Hex-a-hop(6)

NAME
hex-a-hop - puzzle game based on hexagonal tiles DESCRIPTION
Hex-a-hop is a puzzle game based on hexagonal tiles. There is no time limit and no real-time element. The objective is simply to destroy all the green hexagonal tiles on each of the 100 levels. As you progress through the game, more types of tiles are introduced which make things more difficult and interesting. USAGE
You can move the character around with the keys Q,W,E,A,S,D, or with the numeric keypad. Alternatively, you can use the mouse and click on the tile you'd like to move to. Use 'U', backspace or the right mouse button to undo mistakes. The 'Esc' key (or middle mouse button) brings up a menu from which you can restart if you get stuck. Your goal is to break all the green tiles. You mainly do this by jumping on them. They will crack when you land on them, and only disinte- grate when you jump off. Try not to trap yourself! During the game, you will be given hints and instructions on what to do. Use the cursor keys or click on the arrows to scroll through the help pages. More pages will be added as you progress through the game, as new tiles will keep appearing. You can choose which level to attempt next from the map screen. Silver levels are ones you've cleared. Black levels are ones you haven't completed yet, but are available to play. There is no time limit and no real-time element, so take as long as you like. SEE ALSO
You can find more about the game on its homepage: http://www.aceinternet.co.uk/~mokona/ In Debian's version, game data is stored in the directory $HOME/.hex-a-hop/. If the environment variable $HOME is not set, it'll use /tmp/ instead. AUTHOR
The game has been written by Tom Beaumont, and is distributed under the GNU General Public License, either version 2 of the License, or (at your option) any later version. Hex-a-hop(6)
All times are GMT -4. The time now is 02:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy