O
O
Ogurchik-0072022-03-14 16:17:40
C++ / C#
Ogurchik-007, 2022-03-14 16:17:40

What causes the ld returned 1 exit status error?

When I try to compile the code, I get the error ld returned 1 exit status. Compilation problems occur during the passing of the last argument function. How to fix it?

#include<iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
void inputArray(int B[24][14], int i, int j) { 
  srand(time(0));
  for (i = 0; i < 24; i++) {
    for (j = 0; j < 14; j++) {
      B[i][j] = (rand( )%100 - 50); 
    } 
  };
}
void printArray(int B[24][14], int i, int j) { 
  for (i = 0; i < 24; i++) {
    for (j = 0; j < 14; j++) {
      cout<<setw(5)<<B[i][j];
    } 
    cout<<endl;
  }
}
void processingArray(int *B, int k);
int main() {
  setlocale(LC_ALL, "Russian");
  int B[24][14], i=0, j=0;
  inputArray(B, i, j);
  printArray(B, i, j);
  cout<<endl<<endl;

  processingArray(B[i], 14);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2022-03-14
@wataru

Above is written undefined reference to 'processingArray(int*, int)'

Well. You have the processingArray function declared, but not implemented anywhere. Where is the body of the function? Since you declared it, the compiler swallowed this mess and hoped that this function was implemented in another file and that it would be found at the linking stage. But the linker didn't find it, because it's nowhere to be found.
You, apparently, did not rewrite everything from the textbook. There, after the main function, most likely there is an implementation of the processingArray function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question