I am getting the following error while compiled using gdb:
/tmp/ccYfysv0.o: In function `main':
main.c:(.text+0xf1): undefined reference to `reverse'
collect2: error: ld returned 1 exit status
other answers say it might be due to mispelling of the function name, but here is the code that I am trying to compile.
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int reverse(int,int,int*);
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int temp,n,i;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
int y = reverse(n,(int)0,&a[0]);
int reverse(int o,int k,int* p){
temp = *(p+k);
*(p+k)=*(p+o);
*(p+o) = temp;
o=o-1;k=k+1;
if(o==k)
{
return 0;
}
else if((k+1)==o){
temp = *(p+k);
*(p+k)=*(p+o);
*(p+o) = temp;
return 0;
}
else{
reverse(o,k,p);
}
}
for(i=0;i<n;i++)
printf("%d",a[i]);
return 0;
}
But when I compile it with g++, I get the following error:
expected a ';'
could someone please help me out with this problem.