linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Newbie Question -> writing Hexadecimal values
@ 2003-09-25 21:11 Sapuglha
       [not found] ` <3F735CC4.5030507@ig.com.br>
  0 siblings, 1 reply; 5+ messages in thread
From: Sapuglha @ 2003-09-25 21:11 UTC (permalink / raw)
  To: linux-c-programming

Hello people,

my problem is:

I have an hexadecimal value. It's char, but correspond to an hexa value. Then I
want to write it to a file. But in the file, if viewed in hexa (ie. using
hexdump) I want to see "3e" and not the correspondig values in hexa to "3" and
to "e".

An example that works:

	fprintf(test, "%c", 0x3e);

But in my case "3e" is stored in a variable, so I'd like to use something like:

	strcmp(variable, "3e");
	fprintf(test, "%c", variable);

Is it possible? Any light?

Thanks 

-- 
 
=> Tiago Sant' Anna - Linux user #136940
	[.. ..]

^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: Newbie Question -> writing Hexadecimal values
@ 2003-09-25 21:36 Sandro Dangui
  2003-09-25 21:38 ` Sapuglha
  0 siblings, 1 reply; 5+ messages in thread
From: Sandro Dangui @ 2003-09-25 21:36 UTC (permalink / raw)
  To: sapuglha, linux-c-programming


First, you have to convert the string value to an integer value.
After that, you are able to use the integer value do to what you want...

<snip>
char strValue[] = {"3e"};
int value;

if (sscanf(strValue, "%x", &value) == 1) // converts.
{
	fprintf(test, "%c", value);
}
<snip>






-----Original Message-----
From: Sapuglha [mailto:sapuglha@yahoo.com.br] 
Sent: quinta-feira, 25 de setembro de 2003 18:11
To: linux-c-programming@vger.kernel.org
Subject: Newbie Question -> writing Hexadecimal values


Hello people,

my problem is:

I have an hexadecimal value. It's char, but correspond to an hexa value.
Then I want to write it to a file. But in the file, if viewed in hexa (ie.
using
hexdump) I want to see "3e" and not the correspondig values in hexa to "3"
and to "e".

An example that works:

	fprintf(test, "%c", 0x3e);

But in my case "3e" is stored in a variable, so I'd like to use something
like:

	strcmp(variable, "3e");
	fprintf(test, "%c", variable);

Is it possible? Any light?

Thanks 

-- 
 
=> Tiago Sant' Anna - Linux user #136940
	[.. ..]
-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-09-25 22:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-25 21:11 Newbie Question -> writing Hexadecimal values Sapuglha
     [not found] ` <3F735CC4.5030507@ig.com.br>
2003-09-25 21:35   ` Sapuglha
2003-09-25 22:36     ` Jeff Woods
  -- strict thread matches above, loose matches on Subject: below --
2003-09-25 21:36 Sandro Dangui
2003-09-25 21:38 ` Sapuglha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).