关于文件操作中文件标记的问题int main(){\x05FILE *fp;\x05int num,ps;\x05float score;\x05fopen_s(&fp,"stu.txt","w+");\x05scanf_s("%d%f",&num,&score);\x05while (num = 0)\x05{\x05\x05fprintf(fp,"%d,%f\n",num,score);\x05\x05ps = ftell(fp);\x

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 01:06:22
关于文件操作中文件标记的问题int main(){\x05FILE *fp;\x05int num,ps;\x05float score;\x05fopen_s(&fp,
xTmkP+!B;(L  4aBb ܺ}Ѧ8eH&5Z⯹'b'[Kyyιys/7@%N~&q.=9kN/{%Icv%)[}3Ay~N5QkZU2N%gR3Yf5C[)cw!S'\BؖX'?EŽƋ"p]y#p?ϸ"1KB,K>bNXCaќM!|a3s(DAO!\JI*ζ M/opEⲱuө] QVH {Ld&mЯhk[9qn4a>M0Ns0YAk`ų abWAYvgU?;8AMA1܋Cqj=qڸB= ˭̊π۹P6c

关于文件操作中文件标记的问题int main(){\x05FILE *fp;\x05int num,ps;\x05float score;\x05fopen_s(&fp,"stu.txt","w+");\x05scanf_s("%d%f",&num,&score);\x05while (num = 0)\x05{\x05\x05fprintf(fp,"%d,%f\n",num,score);\x05\x05ps = ftell(fp);\x
关于文件操作中文件标记的问题
int main()
{
\x05FILE *fp;
\x05int num,ps;
\x05float score;
\x05fopen_s(&fp,"stu.txt","w+");
\x05scanf_s("%d%f",&num,&score);
\x05while (num = 0)
\x05{
\x05\x05fprintf(fp,"%d,%f\n",num,score);
\x05\x05ps = ftell(fp);
\x05\x05printf("ps=%d",ps);
\x05\x05scanf_s("%d%f",&num,&score);
\x05}
\x05rewind(fp);
\x05while feof(fp))
\x05{
\x05\x05fscanf_s(fp,"%d,%f",&num,&score);
\x05\x05printf("num=%d,score=%f\n",num,score);
\x05}
\x05fclose(fp);
}
为什么输入后ps=13,与设想的数据字节数不同啊?
float是4个字节吧,应该是8个字节一共.我的老师说可能与内存对齐有关,但是具体是什么样子的呢?

关于文件操作中文件标记的问题int main(){\x05FILE *fp;\x05int num,ps;\x05float score;\x05fopen_s(&fp,"stu.txt","w+");\x05scanf_s("%d%f",&num,&score);\x05while (num = 0)\x05{\x05\x05fprintf(fp,"%d,%f\n",num,score);\x05\x05ps = ftell(fp);\x
整型4字节
float8字节
写完之后,就到了13字节,你觉得应该是几字节?