C语言 fwrite问题

来源:百度知道 编辑:UC知道 时间:2024/05/12 07:40:59
struct point
{
int x;
int y;
};
file = fopen("c:\\test.txt","wb");
for(i=0;i<20;i++)
{
pt[i].x=pt[i].y =i;
fwrite(&pt[i],sizeof(struct point),1,file);
}
fclose(file);
代码如上,但是文本文件中没有内容,什么原因。

struct point
{
int x;
int y;
};
file *fp
fp = fopen("test","wb+");
for(i=0;i<20;i++)
{
pt[i].x=pt[i].y =i;
fwrite(&pt[i],sizeof(struct point),1,fp);
}
fclose(fp);

怎么pt没有定义?你是怎么定义pt的?写出来让大家看看。

试试c:\\\test.txt