![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Can somebody look at this and point out any errors to meIt is compiling but I"m having linking errors.
inking... 4th group project.obj : error LNK2001: unresolved external symbol "void __cdecl printResultcharges(float *,float *,float *,float *,float *,float *)" (?printResultcharges@@YAXPAM00000@Z) 4th group project.obj : error LNK2001: unresolved external symbol "void __cdecl printResultmeasurements(int *,int *,int *)" (?printResultmeasurements@@YAXPAH00@Z) 4th group project.obj : error LNK2001: unresolved external symbol "void __cdecl calculate(int *,int *,int *,float *,float *,int *,float *,float *,float *,float *,float *,float *)" (?calculate@@YAXPAH00PAM10111111@Z) 4th group project.obj : error LNK2001: unresolved external symbol "void __cdecl getData(int *,int *,int *,float *)" (?getData@@YAXPAH00PAM@Z) 4th group project.obj : error LNK2001: unresolved external symbol "int __cdecl calcTotal(float *,float *,float *)" (?calcTotal@@YAHPAM00@Z) 4th group project.obj : error LNK2001: unresolved external symbol "int __cdecl calcSubtotal(float *,int *)" (?calcSubtotal@@YAHPAMPAH@Z) 4th group project.obj : error LNK2001: unresolved external symbol "int __cdecl calcInstall(float *,float *,float *)" (?calcInstall@@YAHPAM00@Z) Debug/4th group project.exe : fatal error LNK1120: 7 unresolved externals Error executing link.exe. 4th group project.exe - 8 error(s), 0 warning(s) CPP / C++ / C Code:
|
|
#2
|
||||
|
||||
|
unresolved external symbol
The specified symbol (variable, function, et al) has not been defined. 1) check your parameters to make sure the prototype, the function definition, and the parameters on the call match. 2) format your code bett than this. There's way too many blank lines and not enough or inconsistant indentation __________________
Age is unimportant -- except in cheese |
|
#3
|
|||
|
|||
|
I have extracted the function getData() for purposes of illustration.
Consider CPP / C++ / C Code:
Note that the function declaration is exactly the same as its prototype (same number of arguments, same type of arguments, in the same order). OK, now look at the implementation of the function: Now, for this function you have declared that length is a pointer to an int, so scanf() uses length as its argument. Also, back in main(), for debug purposes, I suggest that you always print out the values that were changed in the function before you continue with calculations using the values Does this get you started? You can add the other functions, one at a time, and debug them as you go. (Just a suggestion --- start with something that works and implement it incrementally.) Dave |
|
#4
|
|||
|
|||
Here is my revised code but my calculations aren't working correctlyCPP / C++ / C Code:
|
|
#5
|
||||
|
||||
|
Please ask a specific question with enough information that we understand the problem and post the code with the problem you are having. We don't usually need the entire program to search thru to find an ambuguously defined problem.
And take another look at your formatting. Your intenting is still inconsistant. Try not to use tabs but spaces. __________________
Age is unimportant -- except in cheese |
|
#6
|
|||
|
|||
|
I'm sorry Walt but I'm trying and learning. This program compiles and runs but the output is just zero. Thanks for your help
|
|
#7
|
|||
|
|||
|
Quote:
Here's a suggestion: Start with the getData(): In the main program, print out all values that were obtained from getData(). Try something like this: CPP / C++ / C Code:
If this is not OK, put printf() statements inside the getData() function to see what's happening. If getData() gives you good data, then go to the next function that you call from main(). That's calculate(). Go inside calculate() and printf() all values coming into the function. This makes sure that you are passing the correct data to the function. Now, use printf() after each calculation to see if the results are what you expect. Continue in this manner, inserting printf() as you go into each function, as you perform calculations, and as you leave each routine. If this sounds tedious, too bad. I claim that it's still faster than posting an appeal for help and waiting for a helpful response. I always like to say, "printf() is your friend." Good Luck!!! Dave |
|
#8
|
||||
|
||||
|
Hi Soulfly. I think that some of your confusion is coming when you are passing pointers into your functions. The only reason that I would pass a pointer to a function is when I need to change the value of that parameter, but for just printing the value, there is no reason to pass a pointer. If you do pass a pointer however, make sure that you are indexing properly for your function.
For example, printf unlike scanf does not take the address of the variable, but the variable itself, so in your functions, you need to change your printfs as follows: CPP / C++ / C Code:
However, my recommendation would be to change the entire function to this: CPP / C++ / C Code:
Also, while I am making recommendations, have you ever thought of throwing this into a structure? It sure would make passing it easier, IMHO. Good luck, d |
Recent GIDBlog
Developing GUIs with wxPython (Part 3) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The