| EGoodman (36) | |
|
I am trying to get a simple program to work but keep getting a LNK1561 error. What am i doing wrong here. The main code < #include <iostream> #include <fstream> #include "average.h" using namespace std; int start() { cout << "this is to find the average of 5 numbers."; cout << endl; ifstream average; cin.get(); cin.get(); return 0; } > The header file < #include <cmath> int avg( int average); > the cpp for the average < #include <iostream> #include "average.h" #include <cmath> using namespace std; int num[4]; int counter; int sum; int averages; int avg(int average) { counter = 0; while(counter <= 4); { cout << "enter a number "; cin>> num[counter]; counter ++; } cout <<endl; sum = 0; for (counter = 0; counter < 4; counter ++) sum = sum + num[counter]; averages = (sum / 5); cout << "the average of your numbers was "; cout << averages; return (averages); } > I could really use some help with this. Need an answer as soon as possible and it has to remain as separate files. | |
|
Last edited on
|
|
| kbw (5375) | |
| Can you print the error as the linker printed it please. | |
|
|
|
| Gulshan Singh (46) | |
| A linker error means the issue is not with the actual code but the files and method definitions. Post the full error and post average.h. Also, use click the <> to format your code with code tags. | |
|
|
|
| EGoodman (36) | |
|
1>------ Build started: Project: Goodman-files, Configuration: Debug Win32 ------ 1>Build started 12/2/2012 9:20:26 PM. 1>InitializeBuildStatus: 1> Touching "Debug\Goodman-files.unsuccessfulbuild". 1>ClCompile: 1> All outputs are up-to-date. 1>LINK : fatal error LNK1561: entry point must be defined 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:00.19 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== The errors | |
|
|
|
| EGoodman (36) | |||||||
main code
header had to move most declarations to avg cpp to get to work.
avg cpp
| |||||||
|
|
|||||||