求救 怎么将dbf转成txt的同时在每个数据后面加逗号
之前看过有将dbf转成xls跟txt的代码 如下 但不知怎么修改令它显示的数据后面有逗号#define M 100
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
void main()
{
FILE *fp, *out1, *out2;
unsigned int recno, headlength, reclength;
unsigned long recnumber;
unsigned char t1, t2, t3, t4;
char fname[13], str[M], oname[13], outname[13];
int i;
printf("请输入要转换的\n");
printf("文件名(.dbf):\n");
gets(fname);
printf("输出文件(.txt):\n");
gets(oname);
printf("输出文件(.xls):\n");
gets(outname);
if(strchr(fname, 0x2e) == NULL)
{
strcat(fname, ".dbf");
}
if(strchr(oname, 0x2e) == NULL)
{
strcat(oname, ".txt");
}
if(strchr(outname, 0x2e) == NULL)
{
strcat(outname, ".xls");
}
if((fp = fopen(fname, "rb+")) == NULL)
{
printf("文件不存在%s\n", fname);
getch();
exit(0);
}
if((out1 = fopen(outname, "wb+")) == NULL)
{
printf("不能打开文件%s\n", outname);
getch();
exit(0);
}
if((out2 = fopen(oname, "wb+")) ==NULL)
{
printf("不能打开文件%s\n", oname);
getch();
exit(0);
}
while(! feof(fp))
{
fputc(fgetc(fp), out1);
}
if (fputc(fgetc(fp), out1) != EOF)
{
printf("转换xls成功\n");
}
fseek(fp, 4L, 0);
fscanf(fp, "%c%c%c%c", &t1, &t2, &t3, &t4);
recnumber = t1 + t2*0x100 + t3*0x10000 + t4*0x1000000;
fseek(fp, 8L, 0);
fscanf(fp, "%c%c", &t1, &t2);
headlength = t1 + t2*0x100;
fseek(fp, 10L, 0);
fscanf(fp, "%c%c", &t1, &t2);
reclength = t1 + t2*0x100;
fseek(fp, headlength, 0);
for(recno = 1; recno <= recnumber; recno++)
{
fgets(str, reclength+1, fp);
fputs(str, out2);
}
if (fputs(str, out2) != EOF)
{
printf("转换txt成功\n");
}
fclose(fp);
fclose(out1);
fclose(out2);
getch();
}