how to stop this proccess prematurely..
i need to enter numbers in a row
of certain length.
if i deside size =3
then i have to input 3 2 7
if i press enter in the middle of the proccess it doesnt stop'
it just enters a new line and continues from there
i want it to sent an error instead.
so if i will press 3 2 enter
it will return an error
i tried to do it here // in the commented line "\n line"
its now working??
Code:
#include <stdio.h>
int read_array(int input[],int i,int size);
int main()
{
int i;
int input[40];
printf("%d\n",read_array(input,0,8));
for(i=0;i<8;i++)
{
printf("%d ",input[i]);
}
printf("\n");
}
int read_array(int input[],int i,int size)
{
int flag,rt;
if (i==size)
{
return 1;
}
flag=scanf("%d",&input[i]); "\n line"
if (input[i]=='\n')
{
return 0;
}
if (flag==0)
{
return 0;
}
else
{
}
rt=read_array(input,i+1,size);
return rt;
}