What is the best way to convert a ascii to hex or decimal?
Below I take the two returned values and concatenate the the second byte of the first hex value to the first two bytes for the second returned values. Then I need to take the return value of "194" string(hex value) and convert is back to decimal format.
My decimal value 194(hex) to 404(decimal)?
Currently I am using a NI DAQ 6534 unit that returns all value into a decimal format(16 bit).
#include <ansi_c.h>
#include <formatio.h>
#include <utility.h>
#include <cvirte.h>
int HEX = 62677;
int HEX1 = 6432;
unsigned char read_data[8];
unsigned char read_data1[8];
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
Fmt (read_data, "%s<%x", HEX);//i is the index location, w is the width in bytes
Fmt (read_data1, "%s<%x", HEX1);//i is the index location, w is the width in bytes
Fmt (read_data, "%s<%s[i1w1]", read_data);//i is the index location, w is the width in bytes
Fmt (read_data1, "%s<%s[i0w2]", read_data1);//i is the index location, w is the width in bytes
strncat (read_data1,read_data, 2);
Delay(1);
return 0;
}
Message Edited by chinook on 02-12-2006 08:33 AM