I am trying to return an array from a local function to the main function but every time it shows a compilation error of
invalid conversion from ‘int’ to ‘int*’ [-f permissive]
#include <bits/stdc++.h>
using namespace std;
int* GCDstrings(int a,int b,int *F)
{
int i;
if(a%b==0)
{
F[0]=1;
for(i=1;i<a;i++)
F[i]=0;
}
return F;
}
int main()
{
int T;
cin>>T;
while(T--)
{
int x,y;
cin>>x>>y;
int f[x];
int* p;
p=GCDstrings(x,y,f[x]);
for(int i=0;i<=x;i++)
cout<<*(p+i);
}
return 0;
}
What is the mistake I am doing here?
std::vector?for(int i=0;i<=x;i++)will access the one past the end pointer...