Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

string to integer conversion question

Hi,

I would like to convert a string captured from the serial port to integer. Here are the codes that I used:

char TempSP[20];
int SPInt;

ComRdTerm (Port1,TempSP,3,10); returned string: TempSP = "5DC"

1. Use Scan function: Scan(TempSP,"%s>%i",&SPInt); returned SPInt = 5
2. Use Fmt function: Fmt(&SPInt,"%i<%s",TempSP); returned SPInt = 5

Expected result: 1500

I am hoping some of you may be able to help me with this.

Thanks in advance.

Tony
0 Kudos
Message 1 of 3
(2,905 Views)
SPInt = (int) strtol(TempSP, NULL, 16);
0 Kudos
Message 2 of 3
(2,901 Views)
For other customers,

This reply has been answered on the following post.

Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 3 of 3
(2,878 Views)