C :: External Errors / Unable To Exit Via Switch Case

Oct 12, 2013

The basics of the program is that:It will ask the user whether they want to: Pop, Push , Peek or Exit the program.

When it comes to the Exit case: how do so( tried exit(1) & exit(0) using the internet hasn't brought me much luck either. I am getting these two errors also:

"Error LNK2019 : Unresolved external symbol "int_cdcel peek(void)" (?peek@@YAHXZ)"

Each applying to the functions below.

"Error LNK1120: 3 Unresolved Externals"

I'm not sure their is much more I can say about the problem.

Code:

#include "stdafx.h"#include <stdio.h>
/* Libary Collection.*/
#define MAX 10
/* Define: The max size of what we are working with.*/
int push (void);
int pop(void);
int peek (void);

[code]...

I was also told that I could us if statements instead but, that still will remove the first errors

View 6 Replies


ADVERTISEMENT

C :: Use Switch Case As A Menu To Switch Between Patients

Dec 30, 2014

I am trying to make a program which manages the data of 5 different patients (its an uni assignment), and i want to use a switch case as a menu to switch between the patients. All other functions (as for example putting the infromation on a file) work, but i cant figure out to bring the switch to work. First it asks for the number of the patient which should be worked with, this works perfectly, but afterwards changiung between the persons doesnt work as thought. It should ask everytime after it switches to one patient (i removed some functions to make it easier to read) and then asks to which it should jump next. If i put the number of one case (lets say 3) it just stops the program.

********Example:
user@pc ~/wherever $ ./program
current variables:
jo = 2
a = 0
1 //the entered number
The variable a = 1
patient 1
Enter the number of the next patient2
// and then it closes
**************

The same thing happens if i compile an example code from a book, it writes the first case and then stops.

I looked already through the forum but didnt find a person with a similar problem, maybe i didnt dig deep enough.

I am running Linux Mint 17 and use gcc as compiler.

Code:

include <stdio.h>
#include <stdlib.h>
int a=0;
int jo=2;
int main(void){
printf("current variables:
jo = %d
a = %d

[Code]...

View 13 Replies View Related

C++ :: Unresolved External Symbol Errors

Apr 10, 2013

I'm doing a homework assignment where I have to calculate monthly interest from a starting balance. I've pulled several sections of the code from various parts of the book. So my problem may be that I'm not combining them correctly.

I'm getting the following error:
Error1error LNK2019: unresolved external symbol "public: __thiscall SavingsAccount::SavingsAccount(void)" (??0SavingsAccount@@QAE@XZ) referenced in function _main

The ios flags are new to me and that may be part of the problem. As soon as I can get a working program, I'm going to make the starting balance and interest rate user inputs. But I get seem to get past this error.

// Savings.cpp
// Chapter 10_Problem 10.7
#include <iostream>

[Code].....

View 12 Replies View Related

C/C++ :: VS Errors - Unresolved External Symbol

Jan 14, 2015

This is a file called namespaces.h

#pragma once
namespace mycode {
void foo();
}

This is a file called source.cpp

#include <iostream>
#include "namespaces.h"
namespace mycode {
void foo() {
std::cout << "foo() called in the mycode namespace" << std::endl;
}
}

When I try to run this code i keep getting these errors;

Error1error LNK2019: unresolved external symbol "void __cdecl mycode::foo(void)" (?foo@mycode@@YAXXZ) referenced in function _mainC:UsersHomeDesktopgameDevWin32Project1Win32Project1Source1.objWin32Project1

Error2error LNK1120: 1 unresolved externalsC:UsersHomeDesktopgameDevWin32Project1DebugWin32Project1.exeWin32Project1

this is a win32 console application, like the books says, the book i am working from that is.

View 11 Replies View Related

C++ :: Binary Tree Template - Getting Errors / Unresolved External Symbol

Feb 10, 2013

When I compile the program, I get errors I've never seen before. Here's my program:

Header File
#ifndef BINARYTREE_H
#define BINARYTREE_H
#include <iostream>
using namespace std;

[Code] ....

And my errors
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall BinaryTree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::insertNode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)"

[Code] ....

View 2 Replies View Related

C# :: Switch Case Variable Scope

Jan 31, 2014

Ran into something today that does not make sense:

This compiles: Code: int x = 5;

switch(x) {
case 0:
{
int value = 5;
}
break;

[Code] ....

Ok so it doesn't like int value = 6 b/c of int value = 5 for case 0. However since the value in case 0 is declared within the brackets one would think it has case scope.

So I tried this:

Code: int x = 5;
switch(x) {
case 0:
{
int value = 5;
}
break;

[Code] ....

Now it doesn't like it b/c value has not been declared in case 1:. These two conditions cannot possibly be both true at the same time. You cannot disallow the declaration of value in case 1 b/c it interferes with value in case 0 and at the same time disallow me to use value from case 0 b/c it is not in scope. If it was not in scope then theoretically I should be able to declare value in case 1.

Both MSVS 2012 and 2013 exhibit the same behavior. I checked the standard and it is unclear on the matter.

View 7 Replies View Related

C :: Switch Case Statement Does Not Execute

Feb 11, 2013

Im going through a C tutorial and im going to create a Database as part of the course. Im just in the very beginning of the project so its a very simple program so far.

Code:

#include<stdio.h>
main(){
/*Variabler for att lagra information om skiva*/
char title[200];
char artist[100];
int tracks;
int price;

[Code] ....

The first switch case statement takes me to the menu of choice, 1 or 2. However, chosing menu option one and trying to input a title or artist name, the program crashes.

Next, going into menu option 2 and then trying to print out, for example, title nothing happend. The process just ends.

Again, im sure this simple prototype is full of errors ....

View 1 Replies View Related

C++ :: Case Scope In Switch Statements

Dec 16, 2013

Is it's scope confined to that single case?

char ch;
switch(ch) {
case '1':
using namespace common::section1; //only this case??
break;

[Code] ....

View 8 Replies View Related

C++ :: Switch Statement Without Writing Each Case

May 28, 2014

I was just wondering if a switch statement can work without writing each case, for instance:

{ int age;
age=18;
while (age!=0) {
cout<<"Enter age :"<<endl;
cin>>age;
switch (age) {

[Code] ....

It works only for values specifically entered as a case, for instance if you enter 5 or 15 , it says bicycle, but if you enter anything inbetween it goes to default. Same with 18 and 100. It can't possibly be that you have to enter

case 19:
case 20:
case 21:
case 22:.......up to 100 to include all possible cases.

View 7 Replies View Related

C++ :: Getting Error - Case Value Has Already Appeared In Switch

Dec 11, 2014

I keep getting the error "case value has already appeared in this switch" how do I fix this?

switch (selection) {
case 'A' || 'a':
aFunc(Houses);
break;
case 'B' || 'b': //The error is here
bFunc(Houses);

[code].....

View 3 Replies View Related

C++ ::  switch Case With Enum Types

Jul 4, 2014

I'm trying to convert the enum type {PG, R, G, PG-13, etc.} to strings so i can use it in cout statement but no matter what i put inside switch(), the compiler keeps saying Error: expression must have integral or enum type. What am I doing wrong exactly?

Movie covert_rating(Movie r) {
switch (r) {
case PG:
return "PG";
break;
case R:
return "R";

[code]....

View 4 Replies View Related

C++ :: Menu Program As Switch-Case Structure

Feb 13, 2015

I tried to write a menu program as a switch-case structure with a separate function for a switch-case structure itself. The outcome for it currently is an undesired one

Code:

#include <iostream>
using namespace std;
int menu(int answer);
int main()

[Code].....

The output I get is one where it's just an infinite loop of "Bad choice! Please try again later.".

View 7 Replies View Related

C++ :: Case Switch Statement Half Working?

Jan 31, 2015

was making a somewhat of a Binary to Hex convertor but only 10/15 cases work and the non working are in the middle; 0010, 0011, 0100, 0101, 0110, 0111;;

// Test Code.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <conio.h>
using namespace std;
int main(void)
{int A;
cout << "Enter the binary starting with the MSB

[code]....

View 5 Replies View Related

C/C++ :: Switch Statement Always Prints Default Case?

Feb 25, 2014

#include <stdio.h>
int main () {
int num;
char choice;
printf(" Welcome to a Menu-Demo Program
Please select one of the following actions
R - Programmers Rock!
F - Programming is Fun!
G - Geeks Rule!
X - Exit program
Selection ==>__ ");
do{
choice = getchar();
switch(choice)

[code]......

I am currently writing a simple program that utilizes switch statements. When I run my program, it always displays the message for the default case.

View 4 Replies View Related

C/C++ :: Why Cannot Use Variables Inside A Case In Switch Construct

Feb 26, 2015

If I have an integer variable like int a=9 then in the switch case If i write :

switch(a) {
case 4+a: printf("hii");
}

Then why is this statement a compile-time error that variables cannot be used inside a case statement why does the compiler not subtitutes the values in place of the variables.

View 1 Replies View Related

C :: How To Make A Switch Case Loop After Input Entered

Dec 31, 2013

I'm working on a code that needs to loop a switch case back to the beginning after a certain input is entered.

ex) Code:

printf("Select an option);
printf("1. Play game");
printf("2. Status");
printf("3. Exit");
scanf("%i", &userinput);
switch(userinput);

[Code]...

For my program, I want option 2 to display something, then loop back to "select and option" after the user presses enter. How would I write that? Would i use a while? do while?

View 3 Replies View Related

C :: Switch Case Character Scanf (also Includes Arrays)

Nov 10, 2014

I'm trying to write a code that is read character user 'e' or ' ' space also numbers I mean a number 'e' or space 'e' a number 'e' or space so forth.But i get absurd numbers. The program shows me the added number. If '
' entered the taking numbers will stop(scanf will stop).

Example input:

e 1 8 7 2 3 6
or e 1 e 8 e 7 e 2 e 3 e 6

Code: #include <stdio.h>
#define MAX 10
void addq ( int *, int, int *, int * ) ;
void test();

[Code]....

View 2 Replies View Related

C :: Process For Printing Number Of Times A Switch Case Has Been Used?

Sep 20, 2013

I want to have one case of my switch statement to print out how many times the user has chosen other cases in the switch statement. Such as "You have pressed 2 6 times and 4 3 times."

View 3 Replies View Related

C++ :: Switch Case - Program That Calculates Students Grade

Apr 18, 2013

Trying to write a program that calculates a students grade based on how many assignments have been graded. I am using a switch case since there is a total of 5 assignments, however when I enter case 1, and enter in how many I got out of 100, it just closes the program it doesn't go to the next part.

#include <iostream>
using namespace std;
char calculategrade(int total);
int main() {
// local variable declaration:
char input;

[Code]....

View 6 Replies View Related

C/C++ :: Switch Case - Show Integer Between 1 To 1000 As Words

Sep 21, 2014

I'm brand new to coding, and I'm learning C. To start, I wanted to create a program that would show an integer between 1-1000 as words (such as 157=One Hundred and Fifty Seven)

I'm having trouble with the switch-case function. I know that what I'm doing all works until it hits the switch function. I've tried switching one of the strcpy functions out with a printf, followed by a system("PAUSE") function, and it gave me results, so I know that the switch function is accepting my "hund" integer. I believe my problem lies within the strcpy function, and its use in the case function.

In short, why isn't the strcpy function working in the switch-case function? Below is my code as it is:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int num;
int hund;
char letHund[20];

[Code] .....

View 2 Replies View Related

C/C++ :: Switch Case Statement Not Returning Correct Values

Mar 21, 2015

My code is supposed to read a five to four digit code of a resistor from a file and determine the resistor's nominal, lower and upper tolerance values. I have inputted my file's first resistor code as a string so I could run tests on it but the problem that occurs is that a get the wrong values from my switch-case statements. I have put printfs after the function call to see what the values were and they turned out wrong. If I could get my return values to be right then I could be on my way coding.

#include<stdlib.h>
#include<stdio.h>
double bandNum(char x); // function prototype that will read the resistor value for the first, second and possibly third band
double bandMult(char x); // function prototype that multiplies the resistor by some value of 10
double bandTol(char x); // function prototype that the tolerance of the resistor is multiplied by

[Code] ....

View 5 Replies View Related

C/C++ :: Switch Construct Does Not Allow Negative Values To Be Used Inside A Case?

Feb 26, 2015

I just wanted to ask the reason that why is the below code not checking the case -1 while working for the other case values.

#include<stdio.h>
#include<conio.h>
int main() {
int i=-1;
switch(i-2) {

[Code] ....

So why in the below code the case -1 doesnt run,when the value evaluated by the switch construct is actually a negative integer constant.

View 1 Replies View Related

C :: Simple Multi-Session Calculator / Switch Case And While Loop

Jun 30, 2013

I have a problem with my simple operations calculator code (using C, in Code::Blocks). I am required to use a while loop statement so the user can execute multiple step operations without re-opening the program. When I launch the program, I get through the first session fine, but when I'm on the second session, when entering the two operands and press enter (to calculate), it just gives me the return and say press any key to continue (exit).Here is the code:

Code:

# include <stdio.h>
int main()
{
int num1, num2;
char op;
int finished = 0;
}

[code]....

View 8 Replies View Related

C++ ::  Errors With Using Templates - Unable To Match Function Definition To Existing Declaration

Apr 13, 2013

I've written the following code and keep getting the errors:

Error1error C2244: 'Supermarket<temp>::operator =' : unable to match function definition to an existing declaration
Error2error C2244: 'Supermarket<temp>::setName' : unable to match function definition to an existing declaration
Error3error C2244: 'Supermarket<temp>::setArea' : unable to match function definition to an existing declaration

#ifndef SUPERMARKET_H
#define SUPERMARKET_H

#include<string>
#include<iostream>
using namespace std;

[Code] .....

I moved the files to the .h file, and now I'm getting

Error2error LNK1120: 1 unresolved externals

View 11 Replies View Related

C++ :: Errors With Unresolved Token And Unresolved External Signal

Jul 10, 2013

My program will not run because of error LNK2028 "unresolved token" and error LNK2019 "unresolved external signal" and I do not know why. My teacher says that I need to make the constructor and display functions display class variables in different formats, but I do not know what to do with that. Here are my 3 files:

Header take 2.h:

#pragma once
#include <iostream>
#include <string>
using namespace std;
class Heading {
private:
string company, report;

[Code] ....

Here are the errors:
Error1error LNK2028: unresolved token (0A0003C9) "public: __thiscall Heading::Heading(void)" (??0Heading@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)c:UsersOwnerdocumentsvisual studio 2012ProjectsClassLibrary2ClassLibrary2Source1.objClassLibrary2

[Code] ....

View 2 Replies View Related

C :: How To Get Upper Case And Lower Case Equal

Feb 18, 2015

I just dont know how to get my upper case and lower case equal...heres the program: Write a program to calculate utility cost for ACME UTILITY COMPANY. The company has 3 types of customers (R) residential, (C) Commercial and (G) government. Customers are billed based on the number of kilowatts used and they type of customer they are (R,C,or G).

Residential cusstomers are charged 0.25 cents per kilowatt hour for the first 500kw used, and 0.35 cent per kwh for all kw used over 500.Commercial customers are charged 0.22 cents per kilowatt hour for the first 999kw used, 0.29 cents per kwh for all kw used over 999 kw up to 1999 and 0.45 cents per kwh for all kilowatts used greater than 1999. Commercial customers that use over 2000 kw are charged a special surcharge of 100.0 in addition to the regular charges.

Government customers are charged 0.34 cents for the first 1500 kwh used(<=1500). 0.30 cent for the next 1000 kwh(1501-2500) and 0.25 cents for all kwh used over (>=2501)

in addition residential customer are charged .5% tax on the cost utilities while Commercial customers are 5% tax on the cost of utilities not including the special surcharge Government customers are not charged a tax

Code:

#include <stdio.h>
#include <math.h>
int main(void)
{
int R;
int ct;
int kwh;
int taxes;
int surcharge;
int charge
}

[code].....

the program should quit with Q and calculate the amount owed, utility charge, and surcharge

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved