Error: ld returned 1 exit status
Nov 21, 2018 at 4:49pm UTC
Can't seem to figure out what's the problem, and i never across this type of error
(error: ld returned 1 exit status; undefined reference to `Skaityti(int&, int&)).
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
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void Skaityti (int & nr, int & pmax);
void Spausdinti (int nr, int pmax);
const char Cmax = 100;
int main()
{
setlocale(LC_ALL, "Lithuanian" );
int n;
int pmax;
int nr;
Skaityti (nr, pmax);
Spausdinti (nr, pmax);
return 0;
}
void Skaityti (int & n, int & nr, int & pmax)
{
ifstream fd ("pietus1.txt" );
fd >> n;
int t;
int tsuma=0;
int max;
int min;
//int pmax=-1;
//int nr;
for (int i = 0; i < n; i++)
{
max = -1;
min = 6;
for (int j = 0; j < n-1; j++)
{
fd >> t;
tsuma += t;
if (t > max)max=t;
if (t < min)min=t;
}
tsuma = tsuma - max - min;
if (tsuma > pmax)
{
pmax = tsuma;
nr = i+1;
}
cout << tsuma << endl;
tsuma=0;
}
}
void Spausdinti (int nr, int pmax)
{
ofstream fr ("pietusrez.txt" );
fr << nr << pmax;
fr.close();
}
Nov 21, 2018 at 5:04pm UTC
1 2 3 4
void Skaityti (int & nr, int & pmax);
...
void Skaityti (int & n, int & nr, int & pmax)
{
You function declaration and definition should match.
Nov 21, 2018 at 6:57pm UTC
oh okay, that was a dumb mistake. The teacher said something about removing the "n". Anyway, thank you so much!
Topic archived. No new replies allowed.