0
This is to my function. It gives me error when calling in main function.
This is the header of my function, in the function file1.h
int eleminar_numeros_repetidos(int *vec, int n, int *vec1);
File function1.c:
void organizar_vetor(int *vec, int n){
int i,j;
for(i=0 ; i <n-1; i=i+1)
{
for(j=i+1 ; j<n ; j=j+1)
{
if (*(vec +i) >*(vec+j))
{
int aux =*(vec+i);
*(vec+i)=*(vec+j);
*(vec+j)=aux;
}
}
}
}
int eleminar_numeros_repetidos(int *vec, int n, int *vec1){
organizar_vetor(vec,n);
int i,j;
for(i=0 ; i <n-1; i++)
{
for(j=i+1 ; j<n ; j++)
{
vec[i]=vec1[i];
if (vec1[i] == vec1[j])
{
int k;
for (k = j; k <n-1 ; k++)
{
vec1[k]=vec1[k+1];
j--;n--;
}
}
}
}
return n;
}
Error:
gcc ex09.c
/tmp/ccYQaeVL.o: In function `main':
ex09.c:(.text+0x112): undefined reference to `eleminar_numeros_repetidos'
collect2: error: ld returned 1 exit status
make: *** [ex09.o] Error 1
Your problem is not in the function code in yes. This problem happens when you call a function that is set in one source file from another, but for some reason Linker is not able to link the call with the function itself. It would be more useful for us to be able to help you if you published how you stated the function: name, parameters. You’re using a header file, right? Make sure the function statement in it matches the statement in the source file.
– C. E. Gesser
int eleminar_repeated numbers(int *vec, int n, int *vec1); this is my 1.h function (where the header is) ; - @ C. E. Gesser
– Programador
And in the archive
funcao1.c
, how are you? You also need to ensure that in the file that contains the functionmain
is being given#include "função1.h"
– C. E. Gesser
I updated my post, put more codes in my program. And in my main function I call #include "funcao1.h" @ C. E. Gesser
– Programador