Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > How to convert string contain Hex data into integer

Reply
Thread Tools

How to convert string contain Hex data into integer

 
 
asifjavaid asifjavaid is offline
Junior Member
Join Date: Sep 2008
Posts: 1
 
      09-09-2008
hi all,

I want to convert a string contain hex format '0x15' and what to convert it integer because i want to write data contain by a integer variable in hex format (binary data) into the file.

here is my code

char * str = "0x15";
int value;

FILE FILE *fptrSample = fopen("e:\\sample.txt","rb+");
if (fptrSample)
{
value = atoi(str);// error : - here "str" contains hex data and want output value = 0x15 in integer but value = 0

putc(value,fptrSample);
fclose(fptrSample);
}

after executing this
output is
value = 0

where as i want to the correct output
value = 0x15 so that this binary data will be written in file


can any one help me?.................
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Does string contain A, and if so, does a section of string contain B Jason Carlton Javascript 11 12-08-2009 06:07 PM
Hex Color Codes - Hex 6 <=> Hex 3 lucanos@gmail.com HTML 10 08-18-2005 11:21 PM
How to convert an hex string to a Hex number chirs Javascript 3 12-01-2003 10:06 PM
hex(-5) => Futurewarning: ugh, can't we have a better hex than '-'[:n<0]+hex(abs(n)) ?? Bengt Richter Python 6 08-19-2003 07:33 AM



Advertisments