I'm trying to have my program do word error checking but for some reason its not working i want the user to input either the words car or truck this is what i have done so far!
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
char *vehicle;
int car;
int truck;
int hrsn, minn;
int hrso, mino;
int hr; //final hour
int min; //final minute
hrsn=0;
hrso=0;
minn=0;
mino=0;
hr=0;
min=0;
printf("Where you driving a car or truck?\n");
scanf("%s", &vehicle );
while(vehicle != "car" && vehicle != "truck")
{
printf("Please input the words Car or Truck: ");
scanf("%s",&vehicle);
}
printf("What Hour did the %s enter the lot? (0-23)\n", vehicle);
scanf("%d",&hrsn);
while((hrsn<0 || hrsn>23))
{
printf("\a\a\a Please Input Value from 0-23!\n");
scanf("%d",& hrsn);
}
{
printf("What Minute did the %s enter the lot? (0-59)\n", vehicle);
scanf("%d",& minn);
}
while((minn<0 || minn>59))
{
printf("\a\a\a Please Enter Correct Minute Between 0-59!\n");
scanf("%d",& minn);
}
{
printf("What Hour did the %s leave the lot? (0-23)\n", vehicle);
scanf("%d",& hrso);
}
while((hrso<0 || hrso>23))
{
printf("\a\a\a Please Enter the Correct Time Between 0-23!\n");
scanf("%d",& hrso);
}
{
printf("What Minute did the %s leave the lot? (0-59)\n", vehicle);
scanf("%d",& mino);
}
while(mino<0 || mino>59)
{
printf("\a\a\a PLease Enter the Correct time between 0-59!\n");
scanf("%d",& mino);
}
{
if (hrsn < (hrso - 1) && minn > mino)
{
hrso = hrso - 1;
mino = mino + 60;
}
if (mino - minn > 1 && mino - minn < 30)
{
mino = minn+30;
}
else if (mino - minn > 30 && mino - minn < 60)
{
mino = minn + 60;
}
else
{
mino = minn + 00;
}
hr = (hrso-hrsn);
min = (mino - minn);
printf("Time in %d:%d\n", hrsn, minn);
printf("Time out %d:%d\n", hrso, mino);
printf("Parking Time %d:%d\n", hr, min);
}
return 0;
}