project help (again) :(

I am having trouble getting rid of 2 errors and I'm just about out of ideas.

The errors read as follows:
Error 1 error LNK2019: unresolved external symbol "bool __cdecl plotLine(int,int,int,int,char,int)" (?plotLine@@YA_NHHHHDH@Z) referenced in function _main C:\CS31\Project3\Project3\lines.obj Project3

and

Error 2 error LNK1120: 1 unresolved externals C:\CS31\Project3\Debug\Project3.exe 1 1 Project3





I have attached an image will all 3 separate project files for a school project, and although most of it works well while I don't include this code:

bool plotLine(int r, int c, int dir, int distance, char plotChar, int fgbg);

I cant seem to clear the shown errors when I do include it. The cpp file that causes this error is the first one on the image, titled "lines.cpp". There is a great deal of code in addition to this, but Ive had to restart over to get rid of this error.

As always, thanks for the help, any general guidance is appreciated instead of a resolved code.

image:
http://postimg.org/image/likqzfk8x/

You have the function declaration at the top for plotLine but where is the actual function?

do you mean including something like
plotLine(12, 3, HORIZ, 0, 'E', FG);
outside of the "if" statement section?

The 2 errors still come out :(
No. That is where you call the function. Where do you implement plotLine?

Can't reach your posted link from work. So I'm only guessing that you haven't implemented plotLine.
Last edited on

No, I mean you have declared the function at the top of your lines.cpp file but I don't see the corresponding function it belongs to.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

#include <iostream>
using namespace std;

// you declared yours up here
bool myFunction();

int main()
{

	if (myFunction()) {
		// my function returned true.
	}
	return 0;

}

// the actual function you are missing?
bool myFunction()
{
	// do stuff
	return true; 
}

THanks, I was able to solve that issue. FINALLY. I really appreciate the help from everyone here.
However, I now have another dilemma. I know we covered this in my class, but I forgot the proper way to structure the following situation:

I need to implement this function:
int CmdExec(string cmdstring, char& plotChar, int& mode, int& badPos)


This function parses the command string, ...The current position starts at (1, 1), the current character starts off as plotChar, and the current mode starts as mode. If the command string is syntactically valid, and all plotting commands execute successfully, this function returns 0 when the plotting actions are completed and does not modify the badPos parameter; plotchar will be the (possibly changed) current character and mode will be the (possibly changed) current mode. //

so basically the user is prompted to enter a series of characters to determine how a line will be drawn on a graph, 20x30.
if the user enters acceptable characters(ill post them below), the graph should work. if not, cout some cheeky **** to tell them to try again. or if their entry is outside of the acceptable length, end program. I have just about everything else but cant make this thing work right without errors
these are the series of possible commands that should be allowed
1
2
3
4
5
6
7
8
Horiz [Hh][-][0-9][0-9]
Verti: [Vv}[0-9][0-9]

Fg [Ff]' ' -> isprint {this shouldn't be able to work if blank}
Bg: [Bb]' ' -> same as fg
Clear: Cc
H-20 for char c:s
	a*=10; a +=c-0 


a string input from the user should include only the letters, H(#),V(#), FG || BG, C or c, and any numbers from 1-99 immediately after a letter, as well as the (-)negative symbol. I had the format written in my notes, but I guess I wasn't descriptive enough because whatever I try brings out an error.

again, thanx for the help

Well in the example below I've not bothered implementing the other function parameters but only the string parser related to your question.

Basically the function cycles through the string checking if its a alpha character, if true then it checks if it was a 'H' or 'V', then continues and reads in the digits (or a -), then a switch statement determines the command read in - then its a rinse and repeat from there until it reaches the end of the command string.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

#include <iostream>
#include <string>
#include <ctype.h>  // isalpha and isdigit

using namespace std;

int CmdExec(string cmdstring);

int main()
{
	string myCommandStr = "H10V9H10V-10H-14";

	if (CmdExec(myCommandStr) == 0)
		cout << endl << endl << "Command executed successfully.";
	else
		cout << endl << "There was a problem with your command string.";

	return 0;
}

int CmdExec(string cmdstring)
{
	char command;
	string value;
	int pos = 0;

	if (cmdstring.length() == 0)
		return -1;

	while (cmdstring[pos])
	{
		// have we reached a alpha char?
		if (isalpha(cmdstring[pos])) {
			// yes, was it a valid command?
			if (cmdstring[pos] != 'H' && cmdstring[pos] != 'V')
				return -1;	// error
			else
			{
				value.clear();   // make sure its empty.
				command = cmdstring[pos];  // store command.
				pos++;;

				// catch if the character after a command is not
				// a numberic digit or a minus.
				if (!isdigit(cmdstring[pos]) && cmdstring[pos] != '-')
					return -1;

				// read in the value for the given command and
				// store it in value.  
				do{
					
					value += cmdstring[pos];
					pos++;
					
				} while (isdigit(cmdstring[pos]) || cmdstring[pos] == '-');
				
				// we now have the command and value.  Note that both are 
				// strings and therefore the value variable would need to 
				// be converted to numeric before doing anything with it.

				switch (command)
				{
					case'H':
						// call function to draw horizontal ?
						cout << endl << "Moving Horizontal by " << value;
					break;
					case'V':
						// call function to draw vertical ?
						cout << endl << "Moving Vertical by " << value;
					break;
				}

			}
		}
		else
			pos++;
	}
	return 0;
}



EDIT: Added error checking at line 46 - other things you could add is toupper, because it maybe possible user enters lower-case commands? - just guessing really, your the designer ;-)

Last edited on
Topic archived. No new replies allowed.