|
如何把读取的字段赋值给变量呢,,请教!!
#include "fxlib.h"
#include "math.h"
#include "stdio.h"
#include "string.h"
FONTCHARACTER * char_to_font(const char *cFileName,FONTCHARACTER *fFileName)
{
int i,len = strlen(cFileName);
for(i=0; i<len ;++i)
fFileName = cFileName;
fFileName=0;
return fFileName;
}
int read_text_file (char ** text)
{
int file_handle;
int len;
FONTCHARACTER font_file_name[32];
char_to_font ("[url=]\\\\crd0\\test.csv",font_file_name[/url]);
file_handle = Bfile_OpenFile (font_file_name,_OPENMODE_READ);
/* 检测文件是否创建成功失败时返回值小于零 */
if (file_handle<0)
return -1;
len = Bfile_GetFileSize (file_handle);
*text = (char*)malloc(len+1);
/* 检测申请内存是否成功 */
if (*text==0) return 0;
Bfile_ReadFile (file_handle,*text,len,0);
Bfile_CloseFile(file_handle);
(*text)[len] = '\0';
return 1;
}
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned int key;
char * text,* t2;
int i,j,k,x,y;
char str[81];
double s[7];
i = read_text_file(&text);
x=1;
y=1;
for (j=0;j<100;j++){
sscanf(text+j,"%c",s);
t2=&s;
if (*t2==0x2c || *t2==0x0a){
x++;
y=0;
continue;
}
if (x>8) break;
if (*t2==0x0D) break;
y++;
locate(y,x);
Print((unsigned char *)t2);
}
while(1){
GetKey(&key);
free(text);
}
return 1;
}
#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
int InitializeSystem(int isAppli, unsigned short OptionNum){
return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}
#pragma section
以上代码是引用刘小饕大侠的,,呵呵,, |
|