- 论坛徽章:
- 0
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
FILE *fp;
int i=0;
struct usersprofile
{
char countryname[30];
char language[5];
char IElang[6];
char IME[5];
char KeyboardMap[9];
}users[86]={"Yemen","0401", "ar-YE","2401","00000401"};
for(i=0;i<86;i++)
{
strcpy(users.countryname,"Yemen");
strcpy(users.language,"0401");
strcpy(users.IElang,"ar-YE");
strcpy(users.IME,"2401");
strcpy(users.KeyboardMap,"00000401");
}
fp=fopen("c:\\usersProfile-m","rb");
for(i=0;i<86;i++)
{
fgets(&users,sizeof(struct usersprofile),fp);
fseek(fp,0,1);
printf("%s\n",&users);
}
fclose(fp);
for(i=0;i<86;i++)
{
printf("%-10s %-5s %-5s %-5s %-8s\n",users.countryname,users.language,users.IElang,users.IME,users.KeyboardMap);
}
}
哪位大虾帮忙看看,为什么结构体输出的结果不对?该怎样修改阿?
预想的输出是这样的:
我的文件usersprofile_m的每行有五项,想把这五项分别保存到struct对应的项中
[ 本帖最后由 huasd1109 于 2007-7-1 11:56 编辑 ] |
|