確かに問題はアドレスまたはポインタであると思いますが、見つけられません。誰かが問題を説明することはできますか?スキャンされた情報が正しく表示されない理由がわかりません
私の問題は、プロンプトが表示されたら入力した内容を印刷しないことです。
#include <stdio.h>
#include <stdlib.h>
void getData(int* enterhour, int* enterminute, int* exitotalhour, int* exminute);
void rate(int exitotalhour, int exminute, int enterhour, int enterminute, int* totalhour, int* totalminute, int* round);
void charge(char* vehic, float* rate1, float* rate2, int enterhour);
void result(int* exitotalhour, int* exminute, int* enterhour, int* enterminute, int* totalhour, float* rate1, float* rate2, int* round, float* total);
int main(void)
{
char vehic;
int enterhour;
int enterminute;
int exitotalhour;
int exminute;
int totalhour;
int totalminute;
int round;
float rate1;
float rate2;
float total;
getData(&enterhour, &enterminute, &exitotalhour, &exminute);
rate(exitotalhour, exminute, enterhour, enterminute, &totalhour, &totalminute, &round);
charge(&vehic, &rate1, &rate2, enterhour);
total= rate1 + rate2;
result(&exitotalhour, &exminute, &enterhour, &enterminute, &totalhour, &rate1, &rate2, &round, &total);
return 0;
}
void getData(int* enterhour, int* enterminute, int* exitotalhour, int* exminute)
{
char v;
printf("Enter c for car, b for bus, t for truck: ");
scanf("%c", &v);
printf("\nHour vehicle entered 0-24: ");
scanf("%d", &enterhour);
printf("\nMinute vehicle entered 0-60: ");
scanf("%d", &enterminute);
printf("\nHour vehicle exited 0-24: ");
scanf("%d", &exitotalhour);
printf("\nMinute vehicle exited 0-60: ");
scanf("%d", &exminute);
return;
}
void rate(int exitotalhour, int exminute, int enterhour, int enterminute, int* totalhour, int* totalminute, int* round)
{
if(enterminute < exminute)
{
enterminute= enterminute + 60;
exitotalhour= exitotalhour - 1;
}
*totalhour = enterhour - exitotalhour;
*totalminute = enterminute - exminute;
if ((*totalminute > 0 && *totalminute <= 60))
{
*totalhour = *totalhour + 1;
*round = *totalminute * 0;
}
return;
}
void charge(char* vehic, float* rate1, float* rate2, int enterhour)
{
switch (*vehic)
{
case 'c': if (enterhour <= 3)
{
*rate1 = 0.00;
if (enterhour > 3)
*rate2 = 1.50 * (float)(enterhour - 3);
}
break;
case 't': if (enterhour <= 2)
{
*rate1 = 1.00 * (float)enterhour;
if (enterhour > 2)
*rate2 = 2.30 * (float)(enterhour - 2);
}
break;
case 'b': if (enterhour <= 1)
{
*rate1 = 2.00 * (float)enterhour;
if (enterhour > 1)
*rate2 = 3.70 * (float)(enterhour - 1);
}
break;
}
return;
}
void result(int* exitotalhour, int* exminute, int* enterhour, int* enterminute, int* totalhour, float* rate1, float* rate2, int* round, float* total)
{
printf("\n\t\t LOT CHARGE \t\t\n");
printf("\nType of vehicle: Car or Bus or Truck");
printf("\nTIME-IN\t\t %d:%d", enterhour, enterminute);
printf("\nTIME-OUT\t\t %d:%d", exitotalhour, exminute);
printf("\n\t\t\t --------");
printf("\nPARKING TIME\t\t %d:%d", totalhour, round);
printf("\n\t\t\t --------");
*total= *rate1 + *rate2;
printf("\nTOTAL CHARGE\t\t %4.2f\n\n", total);
return;
}
コードをインデントして質問に直接投稿してください。 –
そして、無関係な部分を取り除くことを忘れないでください。 –