I have been trying to write a code that can check if there is the sequence of 123 in an array or not for which I made a check function which does that work. But declaring this function before main function is causing problems with compiling when I am writting the arguments in it.
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int check(int, int); /* This line is cauing trouble */
void main()
{ int arr_size;
int a[]={0,1,2,1,2,1,4,5,1,2,3,4,5};
arr_size = sizeof(a)/sizeof(a[0]);
printf("%d",check(a, arr_size));
}
int check(int a[], int arr_size)
{
int i;
for(i=0;i<arr_size-1; i++)
{
if(a[i]==1 && a[i+1]==2 && a[i+2]==3)
{
return 1;
}
}
return 0;
}
The screenshot of the error is attached along.
Declaration part is not causing any problem and the code is working fine when I am not writting any argument in it as shown below.
int check();
I expected that while declaring function it should take the prarameters which is not the case here. Guidance would be appreciated.