D
D
DL11112020-06-12 01:52:56
C++ / C#
DL1111, 2020-06-12 01:52:56

Why does it throw an error Error ld returned 1 exit status?

All my code
#include <iostream>
#include <conio.h>
#include <winbgim.h>
#include <math.h>

#define ESC 27

#define LEFT 75
#define RIGHT 77
#define TOP 72
#define BOT 80

#define RSZP 120
#define RSZM 122

using namespace std;

struct Dot3d
{
  int x, y, z;
};

Dot3d PhotoFrame[32];

int Edges[32][2] = {{1, 2}, {2, 3}, {3, 4}, {4, 1}, {1, 5}, {2, 6}, {3, 7}, {4, 8}, 
          {5, 6}, {6, 7}, {7, 8}, {8, 5}, {9, 10}, {10, 11}, {11, 12}, {12, 9}, 
          {9, 13}, {10, 14}, {11, 15}, {12, 16}, {13, 14}, {14, 15}, {15, 16}, {16, 13}, 
          {5, 13}, {6, 14}, {7, 15}, {8, 16}, {1, 9}, {2, 10}, {3, 11}, {4, 12}};                                                                 

int AngleX = 0;
int AngleY = 0;
int AngleZ = 0;

int Edge = 100;
int Krok = 10;

int variant;

void PaintPhotoFrame(Dot3d *);
void InitPhotoFrame(int, int, int, int);

void OffsetPhotoFrameHorizontal(int);
void OffsetPhotoFrameVertical(int);

void ResPlus(int);
void ResMinus(int);

void Menu();
void Controll();


int main(int argc, char** argv){	
  SetConsoleCP(1251);
  SetConsoleOutputCP(1251);
  setlocale(LC_ALL, "Russian");
  system("color 02");
  Menu();
  
  for (int i = 0; i <= 200; i++)
  {
    printf("> ");
    
    cin >> variant;
    if (variant == 0)
    {
      cout << "Âèõiä" << endl;
      exit(EXIT_SUCCESS);
    }
    
    else if (variant == 1)
    {
      initwindow(800, 800);
      InitPhotoFrame(200,200,0, Edge);
      PaintPhotoFrame(PhotoFrame);
      cleardevice();						
      PaintPhotoFrame(PhotoFrame);
      int v;
      while (v != ESC)
      {
        v = getch();
            
        if (v == RIGHT)  
        {
          OffsetPhotoFrameHorizontal(Krok);	
        }
        else if(v == LEFT)  
        {
          OffsetPhotoFrameHorizontal(-Krok);
        }	
        else if(v == BOT)  
        {
          OffsetPhotoFrameVertical(Krok);	
        }	
        else if(v == TOP)  
        {
          OffsetPhotoFrameVertical(-Krok);
        }
        else if (v == RSZM)  
        {						
          ResMinus(2);
        }
        else if (v == RSZP)  
        {
          ResPlus(2);
        }
      cleardevice();
      PaintPhotoFrame(PhotoFrame);
      }
      system("color 02");
      return 0;
    }
        
    else if (variant == 2)
    {
      
      printf("\033[2;47;35m\033[0m\t");
      cout << "Äîâ³äêà" << endl;
      Controll();
      system("color 02");
    }
  
    else if (variant == 3)
    {
      printf("\033[2;47;35m\033[0m\t");
      cout << "Ïðî àâòîðà" << endl;
      system("color 02");
    }
    
    else
    {
      printf("\033[2;47;35mÂèáåð³òü ïðâèëüíó ä³þ!\033[0m\t\n");
      system("color 02");
      system("cls");
      Menu();
    }
  }
  return 0;
}
void InitPhotoFrame(int x1, int y1, int z1, int m, int n){
  PhotoFrame[0].x=x1;						PhotoFrame[0].y=y1;							PhotoFrame[0].z=z1;
  
  PhotoFrame[1].x=x1+m;					PhotoFrame[1].y=y1;							PhotoFrame[1].z=z1+m/4;
 	PhotoFrame[2].x=x1+m;					PhotoFrame[2].y=y1;							PhotoFrame[2].z=z1-m/4;
  PhotoFrame[3].x=x1-m;					PhotoFrame[3].y=y1;							PhotoFrame[3].z=z1-m/4;
  PhotoFrame[4].x=x1-m;					PhotoFrame[4].y=y1;							PhotoFrame[4].z=z1+m/4;
  
  PhotoFrame[5].x=x1+m;					PhotoFrame[5].y=y1-m*3;						PhotoFrame[5].z=z1+m/4;
  PhotoFrame[6].x=x1+m;					PhotoFrame[6].y=y1-m*3;						PhotoFrame[6].z=z1-m/4;
  PhotoFrame[7].x=x1-m;					PhotoFrame[7].y=y1-m*3;						PhotoFrame[7].z=z1-m/4;
  PhotoFrame[8].x=x1-m;					PhotoFrame[8].y=y1-m*3;						PhotoFrame[8].z=z1+m/4;
  
  PhotoFrame[9].x=x1+m/1.3;				PhotoFrame[9].y=y1-20;						PhotoFrame[9].z=z1+m/5;
  PhotoFrame[10].x=x1+m/1.3;				PhotoFrame[10].y=y1-20;						PhotoFrame[10].z=z1-m/5;
  PhotoFrame[11].x=x1-m/1.3;				PhotoFrame[11].y=y1-20;						PhotoFrame[11].z=z1-m/5;
  PhotoFrame[12].x=x1-m/1.3;				PhotoFrame[12].y=y1-20;						PhotoFrame[12].z=z1+m/5;
  
  PhotoFrame[13].x=x1+m/1.3;				PhotoFrame[13].y=y1-m*2.8;					PhotoFrame[13].z=z1+m/5;
  PhotoFrame[14].x=x1+m/1.3;				PhotoFrame[14].y=y1-m*2.8;					PhotoFrame[14].z=z1-m/5;
  PhotoFrame[15].x=x1-m/1.3;				PhotoFrame[15].y=y1-m*2.8;					PhotoFrame[15].z=z1-m/5;
  PhotoFrame[16].x=x1-m/1.3;				PhotoFrame[16].y=y1-m*2.8;					PhotoFrame[16].z=z1+m/5;

}

void PaintPhotoFrame(Dot3d *c){
  int yt1, yt2, xt1, xt2;
  
  double coefficientZX = sin(AngleX * 3.14 / 180);
  double coefficientZY = cos(AngleX * 3.14 / 180);
  coefficientZX = 0.3;
  coefficientZY = 0.2;
  
  for(int i = 0; i <= 31; i++){
    xt1 = c[Edges[i][0]].x - c[Edges[i][0]].z * coefficientZX;
    yt1 = c[Edges[i][0]].y - c[Edges[i][0]].z * coefficientZY;
    
    xt2 = c[Edges[i][1]].x - c[Edges[i][1]].z * coefficientZX;
    yt2 = c[Edges[i][1]].y - c[Edges[i][1]].z * coefficientZY;
    setcolor(3);
    setlinestyle(SOLID_LINE, 0, 2);
    line(xt1 + 250, yt1 + 250, xt2 + 250, yt2 + 250);
  }
}

void OffsetPhotoFrameHorizontal(int ofs){
  for(int i = 1; i <= 33; i++){
    PhotoFrame[i].x = PhotoFrame[i].x + ofs;
  }
}

void OffsetPhotoFrameVertical(int ofs){
  for(int i = 1; i <= 33; i++){
    PhotoFrame[i].y = PhotoFrame[i].y + ofs;
  }
}

void ResPlus(int r){
  if (Edge != 250){
    Edge = Edge + r;
    InitPhotoFrame(PhotoFrame[0].x, PhotoFrame[0].y, PhotoFrame[0].z, Edge);
  }
  else{
    ResMinus(2);
  }
}

void ResMinus(int r){
  Edge = abs(Edge - r);
  InitPhotoFrame(PhotoFrame[0].x, PhotoFrame[0].y, PhotoFrame[0].z, Edge);
}

void Menu(){
  printf("ÃÅÎÌÅÒÐÈ×Ͳ ÏÅÐÅÒÂÎÐÅÍÍß ÔÎÒÎÐÀÌÊÈ\n");
  printf("Âèáåð³òü îäèí ³ç íàñòóïíèõ ïóíêò³â ìåíþ:\n");
  printf("1 - Äåìîíñòðàö³ÿ ô³ãóðè\n");
  printf("2 - Äîâ³äêà\n");
  printf("3 - Ïðî àâòîðà\n");
  printf("0 - Âèõ³ä\n");
}

void Controll(){
  cout << "Ñòð³ëêè - ïåðåì³ùåííÿ ô³ãóðè" << endl;
  cout << "Z - äëÿ çìåíøåííÿ ô³ãóðè" << endl;
  cout << "X - äëÿ çá³ëüøåííÿ ô³ãóðè" << endl;
  cout << "ESC - äëÿ âèõîäó ç ïðîãðàìè" << endl;
  printf("\033[2;47;35mÏðèì³òêà:\033[0m");
  cout << " äëÿ òîãî, ùîá ôóíêö³¿ ïðàöþâàëè, ïîòð³áíî âèêîðèñòîâóâàòè àíãë³éñüêó ðîçêëàäêó êëàâ³àòóðè" << endl;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-06-12
@jcmvbkbc

Why does it throw an error Error ld returned 1 exit status?

Because you declared and called a function with four arguments, but you defined
void InitPhotoFrame(int, int, int, int);
InitPhotoFrame(200,200,0, Edge);
void InitPhotoFrame(int x1, int y1, int z1, int m, int n)

- with five.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question