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