我试图打印我的代码输出的硬拷贝,但我不确定在我的代码中写入什么才能使输出在显示后立即转换为pdf或txt文件。
下面的代码只是我整个项目的一部分。这将生成我想要在硬拷贝上显示的输出。
float totaldinein()
//This function is to calculate the total price of DINING IN including the 5% government tax and 10% dining in charges.
{
system("cls");
printf("Select your payment method:1--> Cash Payment 2--> Credit Card Payment\n");
scanf("%d",&t);
switch (t)
{
case 1: total1 += (faj+taco+tost+chim+flau+burr+fried)*1.15;
//Calculation for grand total with government taxes,and cash payment.
printf(" Item Price of 1 Total Price \n");
printf(" Fajitas 8.00 $%.2f\n",faj);
printf(" Tacos 5.00 $%.2f\n",taco);
printf(" Tostadas 7.00 $%.2f\n",tost);
printf(" Chimichanga 12.00 $%.2f\n",chim);
printf(" Flautas 10.00 $%.2f\n",flau);
printf(" Burrito 8.00 $%.2f\n",burr);
printf(" Fried ice cream 5.00 $%.2f\n",fried);
printf("\nThe Total is $%.2f\n\n",total1);
break;
case 2: total1 += (faj+taco+tost+chim+flau+burr+fried)*1.18;
//Calculation for grand total with government taxes,and credit card payment.
printf(" Item Price of 1 Total Price \n");
printf(" Fajitas 8.00 $%.2f\n",faj);
printf(" Tacos 5.00 $%.2f\n",taco);
printf(" Tostadas 7.00 $%.2f\n",tost);
printf(" Chimichanga 12.00 $%.2f\n",chim);
printf(" Flautas 10.00 $%.2f\n",flau);
printf(" Burrito 8.00 $%.2f\n",burr);
printf(" Fried ice cream 5.00 $%.2f\n",fried);
printf("\nThe Total is $%.2f\n\n",total1);
break;
default: system("cls");
printf("\nInvalid Error");
}
}
float totaltakeout()
//This function is to calculate the total price of TAKE AWAY including the 5% government tax and 5% dining in charges.
{
system("cls");
printf("Select your payment method:1--> Cash Payment 2--> Credit Card Payment\n");
scanf("%d",&t);
switch (t)
{
case 1: total1 += (faj+taco+tost+chim+flau+burr+fried)*1.10;
//Calculation for grand total with government taxes,and cash payment.
printf(" Item Price of 1 Total Price \n");
printf(" Fajitas 8.00 $%.2f\n",faj);
printf(" Tacos 5.00 $%.2f\n",taco);
printf(" Tostadas 7.00 $%.2f\n",tost);
printf(" Chimichanga 12.00 $%.2f\n",chim);
printf(" Flautas 10.00 $%.2f\n",flau);
printf(" Burrito 8.00 $%.2f\n",burr);
printf(" Fried ice cream 5.00 $%.2f\n",fried);
printf("The Total is $%.2f\n\n",total1);
break;
case 2: total1 += (faj+taco+tost+chim+flau+burr+fried)*1.13;
//Calculation for grand total with government taxes,and credit card payment.
printf(" Item Price of 1 Total Price \n");
printf(" Fajitas 8.00 $%.2f\n",faj);
printf(" Tacos 5.00 $%.2f\n",taco);
printf(" Tostadas 7.00 $%.2f\n",tost);
printf(" Chimichanga 12.00 $%.2f\n",chim);
printf(" Flautas 10.00 $%.2f\n",flau);
printf(" Burrito 8.00 $%.2f\n",burr);
printf(" Fried ice cream 5.00 $%.2f\n",fried);
printf("The Total is $%.2f\n\n",total1);
break;
default: system("cls");
printf("\nInvalid Error");
}
}
发布于 2019-07-22 09:21:15
只需运行程序./ program.exe即可。
但是在命令行上/从终端执行这个程序> mytextfile。
然后你所有的程序输出将被保存在文本文件中。
在程序中做同样的事情会相当复杂,但仍然是可行的。
https://stackoverflow.com/questions/57135081
复制相似问题