Program goes into an infinite loop, no idea why.
Right after I enter the first value for what role, it crashes.
Well I'm guessing it's a loop, but ultimately I have no idea.
Code:
#include <stdio.h>
int main(void)
{
int role, type, permit;
int stickerStudent = 100;
int stickerStaff = 200;
int stickerFaculty = 300;
int hangtagStudent = 150;
int hangtagStaff = 300;
int hangtagFaculty = 450;
printf("What role are you? (1=student, 2=staff, 3=faculty)\n");
scanf("%d\n", role);
if(role == 1)
{
printf("What type of tag do you want? (1=sticker, 2= hang tag)\n");
scanf("%d\n", type);
if(type == 1)
{
permit = stickerStudent;
}
if(type == 2)
{
permit = hangtagStudent;
}
}
if(role == 2)
{
printf("What type of tag do you want? (1=sticker, 2= hang tag)\n");
scanf("%d\n", type);
if(type == 1)
{
permit = stickerStaff;
}
if(type == 2)
{
permit = hangtagStaff;
}
}
if(role == 3)
{
printf("What type of tag do you want? (1=sticker, 2= hang tag)\n");
scanf("%d\n", type);
if(type == 1)
{
permit = stickerFaculty;
}
if(type == 2)
{
permit = hangtagFaculty;
}
}
printf("You need to pay $%d for your parking permit.\n", permit);
system("pause");
return 0;
}
EDIT: I'm an idiot and forgot the & in the scanf.