linker command failed with exit code 1 (use -v to see invocation)

the program seems to be correct but there is this error. who can help me? pleasee

#include<iostream>
#include<stdlib.h>
#define l_max 999999
void carico(float[], int);
void visualizza(float[], int);
void ord_inv(float[], int);
void val_neg(float[], int);
void pos_dis(float[], int);
void sup_med(float[], int);
int main()
{
int N, scelta;
float vett[l_max];
std::cout<<"Inserisci il numero di celle\n";
std::cin>>N;
carico(vett, N);
std::cout<<"1) Visualizza vettore\n";
std::cout<<"2) Visualizza vettore in ordine inverso\n";
std::cout<<"3) Visualizza solo valori negativi\n";
std::cout<<"4) Visualizza valori in posizioni dispari\n";
std::cout<<"5) Visualizza valori superiori alla media\n";
std::cin>>scelta;
std::cout<<std::endl;
switch(scelta)
{
case(1):
visualizza(vett, N);
break;

case(2):
ord_inv(vett, N);
break;

case(3):
val_neg(vett, N);
break;

case(4):
pos_dis(vett, N);
break;

case(5):
sup_med(vett, N);
break;
}
system("PAUSE");
return 0;
}

void visualizza(float vett[], int N)
{
for(int i=0; i<N; i++)
{
std::cout<<vett[i];
}
}

void ord_inv(float vett[], int N)
{
std::cout<<"Il vettore al contrario e': \n";
for(int i=N; i<N; i--)
{
std::cout<<" "<<vett[i]<<std::endl;
}
}

void val_neg(float vett[], int N)
{
for(int i=0; i<N; i++)
{
if(vett[i]>100)
{
std::cout<<vett[i]<<std::endl;
}
}
}

void pos_dis(float vett[], int N)
{
for(int i=0; i<N; i++)
{
if(i%2==0)
{
std::cout<<vett[i]<<std::endl;
}
}
}

void sup_med(float vett[], int N)
{
float media, somma=0;
for(int i=0; i<N; i++)
{
somma+=vett[i];
}
media=somma/(N+1);
for(int i=0; i<N; i++)
{
if(vett[i]>media)
{
std::cout<<vett[i];
}
}
}
You should give the whole compiler error. It actually says
undefined reference to `carico(float*, int)'
collect2.exe: error: ld returned 1 exit status


You call a procedure carico(float*,int) (on line 16).
But you haven't defined a procedure carico(float*,int) anywhere.
Thank you! can you tell me how to solve this problem please? I don't know how to do.
can you tell me how to solve this problem please?


You have to write the procedure carico(float*,int)!
I'm sorry but I can't understand... it already there is at line 4
... it already there is at line 4


That is the declaration of the function. This tells the compiler that the function exists, and is defined somewhere else. Indeed, it is how the compiler comes up with the error.

You need to define the function the same way as you have done for sup_med for example, near the end of the code.

Please always use code tags:
http://www.cplusplus.com/articles/z13hAqkS/

Good Luck !! :+)
I'm becoming crazy, I'm sorry. Can you write exactly what I have to write and where? please
You have to write a function. Do you know what that means? Did you write the code you posted?
yes I did. But I wrote the function because i thought that it was correct. I don't understand what means near the end of the code. Help me
You haven't written the function void carico(float[], int);


Here, see how you wrote this function:
1
2
3
4
5
6
7
8
9
10
void pos_dis(float vett[], int N)
{
  for(int i=0; i<N; i++)
  {
    if(i%2==0)
    {
      std::cout<<vett[i]<<std::endl;
    }
  }
}

That is what you wrote for the function pos_dis

Where the code for carico ?
Last edited on
Oh my days...I'm very sorry. I only forgot to write the function. Thank you very much.
Topic archived. No new replies allowed.