![]() |
| | #1 |
| Registered User Join Date: Mar 2009
Posts: 16
| Can someone tell me why I keep getting so many "fatal" errors I was just wondering if someone could take a look at my program and let me know why I am getting so many errors...It comes up with fatal errors all over the place like for example here is one 1>Project1B.obj : error LNK2019: unresolved external symbol "void __cdecl option_S(void)" (?option_S@@YAXXZ) referenced in function _main I am not exactly sure what it entirely means. Maybe someone could help me out..?? Code: #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
double NohalfDollars;
double Noquarters;
double Nodimes;
double Nonickels;
double Nopennies;
#define quarter .25
#define dime .10
#define nickle .05
#define penny .01
#define half .50
#define MAX 5
void GetText(char *N);
void GetInt(int *I);
void GetDouble(double *F);
void printSummary(char *N,int I,double D);
void display_menu();
char get_choice();
void option_A();
void option_B();
void option_S();
void main()
{
char choice;
do
{
display_menu();
choice = get_choice();
switch(choice)
{
case 'S':
option_S();
break;
case 'A':
option_A();
break;
case 'B':
option_B();
break;
}
} while(choice != 'C');
}
void display_menu()
{
system("cls");
printf("\n~~Select one of the following options~~\n\n");
printf("A-------Option A-The Magic Number!\n");
printf("B-------Option B-Counting Change!\n");
printf("S-------Option S-Summary!\n");
printf("C-------Quit\n");
}
char get_choice()
{
char ch;
do
{
ch = toupper(_getch());
} while (!strchr("ABCS",ch));
return ch;
}
void option_A()
{
int magic,
guess,
tries = 0;
srand( (unsigned)time( NULL ) );
magic = rand()%MAX;
system("cls");
printf("\n\nGuess the random number from 0 to %d\n\n",MAX);
do
{
printf("guess: ");
scanf("%d",&guess);
if(guess == magic)
{
printf("** Right **");
printf("%d is the magic number\n", magic);
}
else
if (guess > magic)
printf(".. Wrong .. Too High\n");
else
printf(".. Wrong .. Too Low\n");
tries++;
} while(guess != magic);
printf("You took %d tries.\n", tries);
printf("\n\n\n\nPress any key to return to the main menu!");
_getch();
}
void option_B()
{ int Nickels=0;
int Half=0;
int Quarters=0;
int Dimes=0;
int Pennies=0;
int Total =0;
double sum =0;
printf("Enter pennies amount: \n");
scanf("%d",&Pennies);
printf("Enter quarters amount: \n");
scanf("%d",&Quarters);
printf("Enter dimes amount: \n");
scanf("%d",&Dimes);
printf("Enter nickels amount: \n");
scanf("%d",&Nickels);
printf("Enter half dollar amount: \n");
scanf("%d",&Half);
printf ("\nYou have entered %d Half Dollars for: $%.2f ",Half,half*Half);
printf ("\nYou have entered %d Quarters for: $%.2f ",Quarters,quarter*Quarters);
printf ("\nYou have entered %d Dimes for: $%.2f ",Dimes,dime*Dimes);
printf ("\nYou have entered %d Nickles for: $%.2f ",Nickels,nickle*Nickels);
printf ("\nYou have entered %d Pennies for: $%.2f ",Pennies,penny*Pennies);
Total=Half+Quarters+Dimes+Nickels+Pennies;
sum = .5 * Half + .25 * Quarters + .05 * Nickels + .10 * Dimes + .01 * Pennies;
printf ("\nYou have entered %d coins with a total of : $%.2f ",Total,sum);
printf ("\n\n\nPress Any Key to Return to the Main Menu ..... ");
_getch();
}
void option_s()
{
char HldText[] = "initial value";
int HldInt;
double HldDbl;
GetText(HldText);
GetInt(&HldInt);
GetDouble(&HldDbl);
printf("\nThis is the the text from main:%s\n",HldText);
printf("\nThis is the integer from main:%d\n",HldInt);
printf("\nThis is the double from main:%.2f\n",HldDbl);
printf("Press any key");
getch();
printSummary(HldText,HldInt,HldDbl);
printf("Press any key");
getch();
}
void GetDouble(double *F)
{
char HldInput[] = "0000000000";
printf("\nEnter Double:");
gets(HldInput);
printf("\nDouble input before conversion:%s\n",HldInput);
*F = atof(HldInput);
printf("\nDouble input after conversion:%.2f\n",*F);
printf("\nPress any key\n");
getch();
}
void GetInt(int *I)
{
char HldInput[] = "00000";
printf("\nEnter integer:");
gets(HldInput);
printf("\nInteger input before conversion:%s\n",HldInput);
*I = atoi(HldInput);
printf("\nInteger input after conversion:%d\n",*I);
printf("\nPress any key\n");
getch();
}
void GetText(char *N)
{
printf("\nEnter text:");
gets(N);
printf("\nPress any key\n");
getch();
}
void printSummary(char *N,int I,double D)
{
printf("\nThis Is from the summary");
printf("\nThis is the the text from summary:%s\n",N);
printf("\nThis is the integer from summary:%d\n",I);
printf("\nThis is the double from summary:%.2f\n",D);
printf("\nPress any key\n");
getch();
}
|
| f4ichick02 is offline | |
| | #2 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,262
| Your compiler is probably complaining about your use of globals, gets, and void main .. that's my bet. Seriously though, if you want a function to take no arguments, make it void, not (). Code: void foo (void); Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? |
| quzah is offline | |
| | #3 |
| Registered User Join Date: Apr 2006
Posts: 1,193
| C is case sensitive. option_s and option_S are not the same function. You define only option_s. The compiler cannot find the definition for option_S.
__________________ It is too clear and so it is hard to see. A dunce once searched for fire with a lighted lantern. Had he known what fire was, He could have cooked his rice much sooner. |
| King Mir is offline | |
| | #4 |
| Registered User Join Date: Mar 2009
Posts: 16
| Thank you so much. I am taking VB, C, and PHP for school so I get a little mixed up sometimes. Thank you so much for the pointers in order to head me to the correct direction! I really appreciate it! |
| f4ichick02 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ten Errors | AverageSoftware | Contests Board | 0 | 07-20-2007 10:50 AM |
| Unknown Errors in simple program | neandrake | C++ Programming | 16 | 04-06-2004 02:57 PM |
| Stupid compiler errors | ChrisEacrett | C++ Programming | 9 | 11-30-2003 05:44 PM |
| Help me with these errors... :-( | major_small | C++ Programming | 6 | 09-07-2003 08:18 PM |
| errors in class(urgent) | ayesha | C++ Programming | 2 | 11-10-2001 06:51 PM |