我做了一个读取csy file的小程序,在tc下编译,运行都完全正确。程序如下:
include "stdio.h"
main()
{
FILE *fp;
int i,j;
double points[10][3];
if((fp=fopen("points.txt","r"))==NULL)
{
printf("cannot open this file");
exit(0);
}
i=0;
while(!feof(fp))
{
fscanf(fp,"%s %s %s",[$points[0],&points[1],&points[2])]
i++;
}
for(j=0;j<i;j++)
{
printf("%s %s %s\n",[$points[j][0],&points[j][1],&points[j][2])]
}
}
但是,相同的一段程序,放在vc中编译后,在ug中却读不了点。甚至把输出格式改为%s,整个ug都会跳出,还请大家一起讨论。
int YIN_RP_apply_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
int i_ret;
char message[133];
tag_t point;
FILE *fp;
int i;
double points[10][3];
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
if((fp=fopen("C:\\points.txt","r"))==NULL)
{
UF_UI_open_listing_window();
UF_UI_write_listing_window("cannot open the file");
}
else
{
for(i=0;i<2;i++)
{
UF_UI_write_listing_window("can open the file");
i_ret=fscanf(fp,"%s %s %s",[$points[0],&points[1],&points[2])]
}
}
fclose(fp);
UF_UI_open_listing_window();
sprintf(message,"%f",points[0][0]);
UF_UI_write_listing_window(message);
UF_terminate ();
return (UF_UI_CB_CONTINUE_DIALOG);
} |