1>check.obj : error LNK2019: unresolved external symbol "void

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 2446 Views - Last Post: 16 October 2012 - 06:29 AM Rate Topic: -----

#1 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 07:50 PM

hi,

writing a code and i'm getting the following compiler error:

1>------ Build started: Project: Lab7_Check, Configuration: Debug Win32 ------
1> check.cpp
1>check.obj : error LNK2019: unresolved external symbol "void __cdecl spell(void)" (?spell@@YAXXZ) referenced in function _main
1>C:\Users\laXrider\documents\visual studio 2010\Projects\Lab7_Check\Debug\Lab7_Check.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Code:

#include <iostream>
#include <string>
void spell ();
using namespace std;

int main(void){

	string date;
	cout << "Enter date: ";
	getline(cin, date);

	string name;
	cout << "Enter name: ";
	getline(cin, name);

	string amountd;
	cout << "Enter amount, dollars: ";
	getline(cin, amountd);

	string amountc;
	cout << "Enter amount, cents: ";
	getline(cin, amountc);

	string payee;
	cout << "Enter payee: ";
	getline(cin, payee);

	cout << "\nYour check: \n\n";
	int insertPointName = name.size();
	int x=50-name.size();
	cout << name.insert(insertPointName,x,' ');
	cout << date << endl;

	cout << "Pay to: ";
	int insertPointPayee = payee.size();
	int y=42-payee.size();
	cout << payee.insert(insertPointPayee,y,' ');
	cout << "$" << amountd << "." << amountc << endl;

	spell(amountd);

}

void spell (string amountd) {

	//inputs the number
	int digit_one=0, digit_two=0;
	amountd;

	if (digit_one == 1)
	{
		switch (digit_two)
		{
		case 0:
			cout << "ten\n";
			break;
		case 1:
			cout << "eleven\n";
			break;
		case 2:
			cout << "twelve\n";
			break;
		case 3:
			cout << "thirteen\n";
			break;
		case 4:
			cout << "fourteen\n";
			break;
		case 5:
			cout << "fifteen\n";
			break;
		case 6:
			cout << "sixteen\n";
			break;
		case 7:
			cout << "seventeen\n";
			break;
		case 8:
			cout << "eighteen\n";
			break;
		case 9:
			cout << "nineteen\n";
			break;

		}
	}
	else
	{
		switch (digit_one)
		{
		case 2:
			cout << "twenty ";
			break;
		case 3:
			cout << "thirty ";
			break;
		case 4:
			cout << "forty ";
			break;
		case 5:
			cout << "fifty ";
			break;
		case 6:
			cout << "sixty ";
			break;
		case 7:
			cout << "seventy ";
			break;
		case 8:
			cout << "eighty ";
			break;
		case 9:
			cout << "ninety ";
			break; 

		}
		switch (digit_two)
		{
		case 1:
			cout << "one\n";
			break;
		case 2:
			cout << "two\n";
			break;
		case 3:
			cout << "three\n";
			break;
		case 4:
			cout << "four\n";
			break;
		case 5:
			cout << "five\n";
			break;
		case 6:
			cout << "six\n";
			break;
		case 7:
			cout << "seven\n";
			break;
		case 8:
			cout << "eight\n";
			break;
		case 9:
			cout << "nine\n";
			break;

		}
	}
}


I have tried changing the way I call my second function and keep getting errors.

Is This A Good Question/Topic? 0
  • +

Replies To: 1>check.obj : error LNK2019: unresolved external symbol "void

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 08:05 PM

Where have you defined a function with the name spell() that takes no arguments? You told the compiler that spell would have no arguments in your function prototype on line 3 yet you never implemented a function named spell with no arguments. Remember your function prototype, function implementation, and function call all must agree as to the number and type of arguments.


Jim
Was This Post Helpful? 1
  • +
  • -

#3 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 08:29 PM

thanks for help but when i change the function definition i'm getting more errors...just going to give up but thanks again
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is offline

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 08:33 PM

Post the new code along with the complete error messages exactly as they appear in your development environment. Then maybe someone can help you find your way out of the fog.

Jim
Was This Post Helpful? 0
  • +
  • -

#5 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 08:52 PM

#include <iostream>
#include <string>
void spell (std::string);
using namespace std;

int main(void){

	string date;
	cout << "Enter date: ";
	getline(cin, date);

	string name;
	cout << "Enter name: ";
	getline(cin, name);

	string amountd;
	cout << "Enter amount, dollars: ";
	getline(cin, amountd);

	string amountc;
	cout << "Enter amount, cents: ";
	getline(cin, amountc);

	string payee;
	cout << "Enter payee: ";
	getline(cin, payee);

	cout << "\nYour check: \n\n";
	int insertPointName = name.size();
	int x=50-name.size();
	cout << name.insert(insertPointName,x,' ');
	cout << date << endl;

	cout << "Pay to: ";
	int insertPointPayee = payee.size();
	int y=42-payee.size();
	cout << payee.insert(insertPointPayee,y,' ');
	cout << "$" << amountd << "." << amountc << endl;

	spell(amountd);
	cout << amountd;

}

void spell (string amountd) {

	//inputs the number
	int digit_one=0, digit_two=0;
	cin >> amountd;

	if (digit_one == 1)
	{
		switch (digit_two)
		{
		case 0:
			cout << "ten\n";
			break;
		case 1:
			cout << "eleven\n";
			break;
		case 2:
			cout << "twelve\n";
			break;
		case 3:
			cout << "thirteen\n";
			break;
		case 4:
			cout << "fourteen\n";
			break;
		case 5:
			cout << "fifteen\n";
			break;
		case 6:
			cout << "sixteen\n";
			break;
		case 7:
			cout << "seventeen\n";
			break;
		case 8:
			cout << "eighteen\n";
			break;
		case 9:
			cout << "nineteen\n";
			break;

		}
	}
	else
	{
		switch (digit_one)
		{
		case 2:
			cout << "twenty ";
			break;
		case 3:
			cout << "thirty ";
			break;
		case 4:
			cout << "forty ";
			break;
		case 5:
			cout << "fifty ";
			break;
		case 6:
			cout << "sixty ";
			break;
		case 7:
			cout << "seventy ";
			break;
		case 8:
			cout << "eighty ";
			break;
		case 9:
			cout << "ninety ";
			break; 

		}
		switch (digit_two)
		{
		case 1:
			cout << "one\n";
			break;
		case 2:
			cout << "two\n";
			break;
		case 3:
			cout << "three\n";
			break;
		case 4:
			cout << "four\n";
			break;
		case 5:
			cout << "five\n";
			break;
		case 6:
			cout << "six\n";
			break;
		case 7:
			cout << "seven\n";
			break;
		case 8:
			cout << "eight\n";
			break;
		case 9:
			cout << "nine\n";
			break;

		}
	}
}



This is my revised code and I'm no longer getting an error. However, my goal is to print out the dollar amount in words in my first function at that point and when it gets to the function call it just doesn't do anything. I'm not getting an error but it isn't working.
Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg  Icon User is offline

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 09:01 PM

Please post a sample of what you inputted into your program.

But why are you passing a parameter into your function then overwriting that value before you ever use it (cin >> amountd;) ?

Jim
Was This Post Helpful? 1
  • +
  • -

#7 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 09:11 PM

Input:
Date: 2/12/2012
Name: Michael Jones
Dollars: 20
Cents: 12
Payee: Target

I wasn't trying to input it I was just trying to use the value. I changed that and I also realized I needed a return and is attached to my new code...however it is saying that name2 is uninitialized and it is outputting '20' which if name2 is going to hold the written version of a number it can't be int but it isn't letting me define the function as 'string spell(amountd)'

#include <iostream>
#include <string>
int spell (std::string);
using namespace std;

int main(void){

	string date;
	cout << "Enter date: ";
	getline(cin, date);

	string name;
	cout << "Enter name: ";
	getline(cin, name);

	string amountd;
	cout << "Enter amount, dollars: ";
	getline(cin, amountd);

	string amountc;
	cout << "Enter amount, cents: ";
	getline(cin, amountc);

	string payee;
	cout << "Enter payee: ";
	getline(cin, payee);

	cout << "\nYour check: \n\n";
	int insertPointName = name.size();
	int x=50-name.size();
	cout << name.insert(insertPointName,x,' ');
	cout << date << endl;

	cout << "Pay to: ";
	int insertPointPayee = payee.size();
	int y=42-payee.size();
	cout << payee.insert(insertPointPayee,y,' ');
	cout << "$" << amountd << "." << amountc << endl;

	spell(amountd);
	cout << amountd;

}

 int spell (string amountd) {

	//inputs the number
	int digit_one=0, digit_two=0;
	amountd;
	
	int name2;

	if (digit_one == 1)
	{
		switch (digit_two)
		{
		case 0:
			cout << "ten\n";
			break;
		case 1:
			cout << "eleven\n";
			break;
		case 2:
			cout << "twelve\n";
			break;
		case 3:
			cout << "thirteen\n";
			break;
		case 4:
			cout << "fourteen\n";
			break;
		case 5:
			cout << "fifteen\n";
			break;
		case 6:
			cout << "sixteen\n";
			break;
		case 7:
			cout << "seventeen\n";
			break;
		case 8:
			cout << "eighteen\n";
			break;
		case 9:
			cout << "nineteen\n";
			break;

		}
	}
	else
	{
		switch (digit_one)
		{
		case 2:
			cout << "twenty ";
			break;
		case 3:
			cout << "thirty ";
			break;
		case 4:
			cout << "forty ";
			break;
		case 5:
			cout << "fifty ";
			break;
		case 6:
			cout << "sixty ";
			break;
		case 7:
			cout << "seventy ";
			break;
		case 8:
			cout << "eighty ";
			break;
		case 9:
			cout << "ninety ";
			break; 

		}
		switch (digit_two)
		{
		case 1:
			cout << "one\n";
			break;
		case 2:
			cout << "two\n";
			break;
		case 3:
			cout << "three\n";
			break;
		case 4:
			cout << "four\n";
			break;
		case 5:
			cout << "five\n";
			break;
		case 6:
			cout << "six\n";
			break;
		case 7:
			cout << "seven\n";
			break;
		case 8:
			cout << "eight\n";
			break;
		case 9:
			cout << "nine\n";
			break;

		}
	}
	return name2;
}



Basically what I'm trying to do is get it to output the input (20) dollar amount as twenty.
Was This Post Helpful? 0
  • +
  • -

#8 jimblumberg  Icon User is offline

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 09:16 PM

Okay so you send this function the string "20", where are you using this string in your spell function?

What is the purpose of your digit_one and digit_two variables?

Also do you know the difference between the values of '0' and 0?

You may also want to review these links: Arrays and Character Sequences.


Jim

This post has been edited by jimblumberg: 15 October 2012 - 09:18 PM

Was This Post Helpful? 0
  • +
  • -

#9 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 09:21 PM

I'm attempting to make '20' in the function spell be broken up to be 2 being digit one and 0 being digit two. It has to work for any input dollar amount between 10 and 99 so it needs to be able to evaluate the string and then go through the switches and assign it a written value.
Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 09:25 PM

Quote

I'm attempting to make '20' in the function spell be broken up to be 2 being digit one and 0 being digit two.

And where are you breaking up this string and placing the two digits into your two variables.

Also remember a string is denoted by double quotes "20" and characters are denoted by single quotes '2', and that there is a difference between the number 2 and the character '2'.


Jim

This post has been edited by jimblumberg: 15 October 2012 - 09:48 PM

Was This Post Helpful? 1
  • +
  • -

#11 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 09:49 PM

#include <iostream>
#include <string>
char spell (std::string);
using namespace std;

int main(void){

	string date;
	cout << "Enter date: ";
	getline(cin, date);

	string name;
	cout << "Enter name: ";
	getline(cin, name);

	string amountd;
	cout << "Enter amount, dollars: ";
	getline(cin, amountd);

	string amountc;
	cout << "Enter amount, cents: ";
	getline(cin, amountc);

	string payee;
	cout << "Enter payee: ";
	getline(cin, payee);

	cout << "\nYour check: \n\n";
	int insertPointName = name.size();
	int x=50-name.size();
	cout << name.insert(insertPointName,x,' ');
	cout << date << endl;

	cout << "Pay to: ";
	int insertPointPayee = payee.size();
	int y=42-payee.size();
	cout << payee.insert(insertPointPayee,y,' ');
	cout << "$" << amountd << "." << amountc << endl;

	spell(amountd);
	cout << spell;

}

 char spell (string amountd) {

	//inputs the number
	int digit_one, digit_two;
	amountd = digit_one, digit_two;

	if (digit_one == 1)
	{
		switch (digit_two)
		{
		case 0:
			cout << "ten\n";
			break;
		case 1:
			cout << "eleven\n";
			break;
		case 2:
			cout << "twelve\n";
			break;
		case 3:
			cout << "thirteen\n";
			break;
		case 4:
			cout << "fourteen\n";
			break;
		case 5:
			cout << "fifteen\n";
			break;
		case 6:
			cout << "sixteen\n";
			break;
		case 7:
			cout << "seventeen\n";
			break;
		case 8:
			cout << "eighteen\n";
			break;
		case 9:
			cout << "nineteen\n";
			break;

		}
	}
	else
	{
		switch (digit_one)
		{
		case 2:
			cout << "twenty ";
			break;
		case 3:
			cout << "thirty ";
			break;
		case 4:
			cout << "forty ";
			break;
		case 5:
			cout << "fifty ";
			break;
		case 6:
			cout << "sixty ";
			break;
		case 7:
			cout << "seventy ";
			break;
		case 8:
			cout << "eighty ";
			break;
		case 9:
			cout << "ninety ";
			break; 

		}
		switch (digit_two)
		{
		case 1:
			cout << "one\n";
			break;
		case 2:
			cout << "two\n";
			break;
		case 3:
			cout << "three\n";
			break;
		case 4:
			cout << "four\n";
			break;
		case 5:
			cout << "five\n";
			break;
		case 6:
			cout << "six\n";
			break;
		case 7:
			cout << "seven\n";
			break;
		case 8:
			cout << "eight\n";
			break;
		case 9:
			cout << "nine\n";
			break;

		}
	}
	return;
}



Ok, I see what you're saying. I attempted to change it but I'm not sure if I did it correctly...I'm getting an error now:

1>------ Build started: Project: Lab7_Check, Configuration: Debug Win32 ------
1> check.cpp
1>c:\users\laxrider\documents\visual studio 2010\projects\lab7_check\lab7_check\check.cpp(150): error C2561: 'spell' : function must return a value
1> c:\users\laxrider\documents\visual studio 2010\projects\lab7_check\lab7_check\check.cpp(3) : see declaration of 'spell'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Isn't the function returning the text as its value?

Also I completely forgot about char, haha.
Was This Post Helpful? 0
  • +
  • -

#12 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 15 October 2012 - 10:00 PM

Since your spell function's return type is char, it should return a character value. So, change that return statement to return a character value.

regards,
Raghav
Was This Post Helpful? 0
  • +
  • -

#13 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 16 October 2012 - 12:03 AM

I am just unsure as to how I can separate the two digit number I get for amountd into two separate numbers to evaluate as a written number.
Was This Post Helpful? 0
  • +
  • -

#14 laxxie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-October 12

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 16 October 2012 - 02:14 AM

So basically I'm extremely confused. When debugging my code I am using a string 'amountd' which is input by the user in the beginning of the program. The input has to be a two digit number and for my example lets say I'm using 20. I have debugged the following code:

int k=0, w=0;
	cout << amountd[0];
	cout << "x";
	cout << amountd[1];


The x is just to separate the two clearly. Basically what I'm trying to do is assign 2 to the variable k and 0 to the variable w. When I output amound[0] it outputs the number 2. When I output amountd[1] it outputs the number 0. However, if I were to type amountd[0] = k and then output k it would output a random number (48 I believe it was). And the same with w. Why is it that amound[0] is clearly 2 and when I set it equal to something it has a problem?
Was This Post Helpful? 0
  • +
  • -

#15 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 615
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: 1>check.obj : error LNK2019: unresolved external symbol "void

Posted 16 October 2012 - 03:06 AM

A string is a sequence of values which map to characters. In this case, I assume you're using ASCII and not other characters sets like Unicode. An ASCII '2' is not the same as the integer value 2. In fact, the ASCII value of '2' is represented as the value 50.

To convert between ASCII values and integer values, you should subtract the ASCII value of '0' (48). For example.

char c = '6'; // '6' is 54 in ASCII
int n = c - (int)'0'; // n = 54 - 48 = 6


Of course, you should first check that your ASCII value actually is '0'-9' before making such calculations.

This post has been edited by Aphex19: 16 October 2012 - 06:02 AM

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2