来自中国的朋友,欢迎您在本版面使用中文讨论问题。请注意,如果您想得到不懂中文的人的帮助,请同时提供英文译文。
Help and discussions in Chinese.
by liqi98136 » Wed Mar 10, 2010 9:22 am
- Code: Select all
import "ecere"
extern scanf();
struct Stu
{
char name[10];
int num;
int age;
char addr[15];
};
class TestFileApp : Application
{
void Main()
{
int i;
Stu boya[2];
Stu boyb[2];
Stu * pp=boya;
Stu * qq=boyb;
File f=FileOpen("stu_list", writeRead);
if(f)
{
printf("\ninput data\n");
printf("%s\t%s\t%s\t%s\n","name","num","age","address");
for(i=0;i<2;i++,pp++)
scanf("%s%d%d%s",pp->name,&pp->num,&pp->age,pp->addr);
pp=boya;
f.Write(pp,sizeof(struct Stu),2);
f.Seek(0,start);
f.Read(qq,sizeof(struct Stu),2);
printf("%s\t%s\t%s\t%s\n","name","num","age","address");
for(i=0;i<2;i++,qq++)
printf("%s\t%5d%7d\t%s\n",qq->name,qq->num,qq->age,qq->addr);
}else
{
printf("open file failed\n");
}
delete f;
system("PAUSE");
}
}
-
liqi98136
-
- Posts: 53
- Joined: Sun Jan 17, 2010 11:37 pm
Return to 欢迎使用中文讨论
Who is online
Users browsing this forum: No registered users and 1 guest