#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
// Function prototypes
void MainMenu();
void PaymentMode();
void get_password();
#define FIELD_SIZE 25
#define length(array) ( sizeof (array) / sizeof (array)[i] )
struct account {
char *id;
char *password;
};
static struct account accounts[] = {
{ "alexander", "iamsolame" },
{ "haisham", "battlefiedheroes" },
{ "albert", "booties" }
};
int is_authorized ( const char *uid, const char *pwd )
{
int i;
for ( i = 0; i < length ( accounts ); i++ ) {
if ( stricmp ( uid, accounts[i].id ) == 0 &&
strcmp ( pwd, accounts[i].password ) ==0 )
{
return 1;
}
}
return 0;
}
void get_password ( char *pwd, int size )
{
int i = 0;
int ch;
while ( i < size - 1 && ( ch = getch() ) != '\r' ) {
if ( ch == '\b' ) {
if ( i != 0 ) {
printf ( "\b%c\b", ' ' );
--i;
}
}
else {
putchar ( '#' );
pwd[i++] = (char)ch;
}
}
pwd[i] = '\0';
}
//Main Method
int main ()
{
char uid[FIELD_SIZE];
char pwd[FIELD_SIZE];
printf("**********Welcome to Kitties Fastfood Restaurant**********\n\n\n\n");
printf("Login by keying in your details below\n\n");
printf ( "User ID: " );
fflush ( stdout );
if ( fgets ( uid, sizeof uid, stdin ) != NULL ) {
char *newline = strchr ( uid, '\n' );
if ( newline != NULL )
*newline = '\0';
printf ( "Password: " );
fflush ( stdout );
get_password ( pwd, sizeof pwd );
if ( is_authorized ( uid, pwd ) )
printf("\n\n\t\t>>USER AUTHENTICATED<<\n");
else
printf("\n\n\t\t<<NO SUCH LOGIN INFORMATION!>>\n");
}
getchar();
MainMenu();
}
void MainMenu()
{
char code;
system("cls");
printf("***Welcome to Kitties FastFood***\n\n\n");
printf("Available menu selection is as below:\n\n");
printf("Item:\t\t\tPrice:\t\tRemarks:\n");
printf("1- Lunch/Dinner Set\tRM8.00\t\t1 burger/chicken, 1 drink (M)\n");
printf("\t\t\t\t\t1 french fries (M)\n\n");
printf("2- Breakfast Set\tRM5.00\t\t1 breakfast, 1 drink (M)\n\n");
printf("3- Kiddies Set\t\tRM6.00\t\t1 buerger/chicken, 1 drink (S)\n");
printf("\t\t\t\t\t1 french fries (S)\n\n");
printf("4- Promotion\t\tRM3.00\t\tburger/chicken\n\n");
printf("5- Drink\t\tRM2.00\t\tMedium size\n\n");
printf("6- French Fries\t\tRM3.00\t\tMedium size\n\n");
printf("7- Dessert\t\tRM3.50\t\tIce cream/pie/cake\n\n");
printf("8- Upgrade meal\t\tRM1.00\t\tSmall to medium/medium to larger\n\n");
printf("\n");
Printf("\n\n\t Please enter the required menu number: ");
scanf( "%d", &code);
//Error Handling
while(code!='1' && code!='2' && code!='3' && code!='4' && code!='5' && code!='6' && code!='7' && code!='8' && code!='Q' && code!='q')
{
printf("\n\n\tNo such menu in offered! Please enter the right menu number: ");
scanf( "%d", &code);
}
switch(code)
{
case '1':
printf("\nTotal: RM8.00");
break;
case '2':
printf("\nTotal: RM5.00");
break;
case '3':
printf("\nTotal: RM6.00");
break;
case '4':
print("\nTotal: RM3.00");
break;
case '5':
printf("\nTotal: RM2.00");
break;
case '6':
printf("\nTotal: RM3.00");
break;
case '7':
printf("\nTotal: RM3.50");
break;
case '8':
printf("\nTotal: RM1.00");
break;
case 'Q':case 'q':
system("cls");
printf("\t You are exiting the system!\n");
break;
}
}
//end of MainMenu()
void PaymentMode()
{
char code;
system("cls");
printf("\t Enter Customer Mode of Payment\n");
printf("\t 1-Credit Card\n");
printf("\t 2-Debit Card\n");
printf("\t 3-Cash\n");
printf("\t 4-He has no money, proceed to kick him out!\n");
scanf("%d", &code);
//Error Handling
while(code!='1' && code!='2' && code!='3' && code!='4' && code!='Q' && code!='q')
{
printf("\n\n\tNo such menu in offered! Please enter the right menu number: ");
scanf( "%d", &code);
}
switch(code)
{
case '1':
printf("\nPayment is now in Credit Card, additional 3% will be charged!");
break;
case '2':
printf("\nNo additonal charges!");
break;
case '3':
printf("\nNo additional charges!");
break;
case '4':
printf("\nNo additional charges!");
break;
case 'Q': case 'q':
system("cls");
printf("\tYou are exiting the system!\n");
break;
}
getchar();
return 0;
}
//end of PaymentMode
Ok guys, as you can see above is the code for the application. I'm still very noob at programming, would really appreciate if you could point out the mistakes there. I know its messy, but help me out please. The login was taken from some post here. I didn't do the login part.
The problem:
When building the solution in MS Visual Studio 2008, had these following errors:
Error 10 error LNK2019: unresolved external symbol _print referenced in function _MainMenu billingsystem.obj Fast Food Billing System_pre
***
Error 11 error LNK2019: unresolved external symbol _Printf referenced in function _MainMenu billingsystem.obj Fast Food Billing System_pre
***
Error 12 fatal error LNK1120: 2 unresolved externals F:\Users\PuttyKitties\Documents\Visual Studio 2008\Projects\Fast Food Billing System_pre\Debug\Fast Food Billing System_pre.exe Fast Food Billing System_pre