2
我想將下面的代碼的輸出緩衝區(字符數組) 轉換爲浮點格式以供進一步計算。 有人可以告訴我該怎麼做。字符數組到浮點數轉換
#include "usbtmc.h"
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
#include <inttypes.h>
#include <sys/types.h>
#include <pthread.h>
int main()
{
int myfile;
char buffer[4000];
int actual;
myfile=open("/dev/usbtmc1",O_RDWR);
if(myfile>0)
{
system("echo MEAS:VOLT:AC?>/dev/usbtmc1");
actual=read(myfile,buffer,4000);
buffer[actual] = 0;
printf("Response = \n %s\n",buffer);
close(myfile);
}
return 0;
}
示例輸出此代碼是
響應= + 1.29273072E-04
不能使用ATOF? http://www.cplusplus.com/reference/cstdlib/atof/ – Shark 2013-04-05 14:45:16