【发布时间】:2018-11-19 09:53:02
【问题描述】:
我是 C 语言的新手,目前我正在开发一个药房系统程序,其中包括插入、更新、删除、搜索、显示功能。 一切正常,除了显示。例如,我的结构包括 Medicode、Mediname、Compname、Date 等。 当我插入超过 7 个字母的字符串时,显示的对齐方式会发生变化,导致显示无法很好地对齐。
显示问题将显示在图像中
void displayall()
{
int emp;
emp = empty();
if (emp == 0)
{
printf("\nSorry, the file is empty.\n");
getch();
}
if (emp != 0)
{
FILE *fp1;
fp1 = fopen("Medicine", "r");
printf("\nMediCode\tMedicineName\tCompanyName\tDateOfManufacture\tDateOfExpiry\t\tPrice\n\n");
while (fread(&medi, sizeof(medi), 1, fp1))
printf("%d\t\t%s\t\t%s\t\t%d\t\t\t%d\t\t %.2f\n", medi.medicode, medi.mediname, medi.compname, medi.DateOM, medi.DateOE, medi.price);
fclose(fp1);
printf("\n\nPress any key to return to Main Menu.");
getch();
}
}
【问题讨论】:
-
只是不要在
printf中使用空格,这样会很棒!