1.出错代码如下
// 例程 7-4 访问ADC
#include "stdafx.h"
#include "conio.h"
#include "windows.h"
#include "gts.h"
//↓↓↓↓↓有关计时的头文件//
#include "stdio.h"
#include "stdlib.h"
//↑↑↑↑↑有关计时的头文件//
#include <ctype.h>
// 该函数检测某条GT指令的执行结果,command为指令名称,error为指令执行返回值
void commandhandler(char *command, short error)
{
// 如果指令执行返回值为非0,说明指令执行错误,向屏幕输出错误结果
if(error)
{
printf("%s = %d\n", command, error);
}
}
int main(int argc, char* argv[])
{
// 指令返回值
short sRtn;
// 电压值
double dGetVoltageValue[4];
// 数字转换值
short sGetDigitalValue[4];
sRtn = GT_Open();
commandhandler("GT_Open", sRtn);
sRtn = GT_Reset();
commandhandler("GT_Reset", sRtn);
// 读取4个通道的输入电压
sRtn = GT_GetAdc(1, &dGetVoltageValue[0], 4);
// 读取4个通道输入电压的数字转换值
sRtn = GT_GetAdcValue(1, &sGetDigitalValue[0], 4);
//↓↓↓↓↓//
FILE *fpt;
fpt = fopen("D:\\test.txt","w");
fputs("This is testing for fputs...\n", fpt);//执行到此出错
fprintf (fpt, "[");//通过文件句柄写入"["//执行到此出错
//↑↑↑↑↑//
return 0;
}
2.错误现象
3.原因猜想一
结果:没去印证这个猜想,不是因为它
4.真实原因
我重装了电脑,根本没有D盘,只有CEF盘!
改成现有的E盘就完全正常了。