如何正确设置对齐文件?
How to set alignment properly to file?
我正在为文件添加一点对齐方式。我在文件中添加了名称,比如说尺寸为 20,这弄乱了我所有的对齐方式!
你知道如何在不使用转义字符的情况下设置文件宽度吗?
以下代码只是学生相关功能的一部分-
void save()
{
FILE* fp;
fp = fopen("Student.txt", "w");
fprintf(fp,"Roll No\tName\t\t\t\tPaper 1\tPaper 2\tPaper 3\tTotal \tGrade\n");
for(int i = 0; i < time; ++i)
{
fprintf(fp, "%d\t%s\t \t%d\t%d\t%d\t%d\t%c\n", info[i].rollNo, info[i].name,info[i].p1, info[i].p2, info[i].p3, info[i].total, info[i].grade);
}
cout << "Successfully written to file!" << endl;
fclose(fp);
getch();
menu();
}
谢谢!!1
我正在为文件添加一点对齐方式。我在文件中添加了名称,比如说尺寸为 20,这弄乱了我所有的对齐方式! 你知道如何在不使用转义字符的情况下设置文件宽度吗?
以下代码只是学生相关功能的一部分-
void save()
{
FILE* fp;
fp = fopen("Student.txt", "w");
fprintf(fp,"Roll No\tName\t\t\t\tPaper 1\tPaper 2\tPaper 3\tTotal \tGrade\n");
for(int i = 0; i < time; ++i)
{
fprintf(fp, "%d\t%s\t \t%d\t%d\t%d\t%d\t%c\n", info[i].rollNo, info[i].name,info[i].p1, info[i].p2, info[i].p3, info[i].total, info[i].grade);
}
cout << "Successfully written to file!" << endl;
fclose(fp);
getch();
menu();
}
谢谢!!1