Every stream has an "end-of-file (EOF) flag". The flag is only cleared if you call the clearerr function on the stream. feof(p) function returns the current state of this EOF flag.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
int i=0;
int arr[100];
while(1){
scanf("%d",&arr[i]);
if(feof(stdin)){
break;
}
i++;
}
int j;
for(j=0;j<i;j++){
printf("%d ",arr[j]);
}
i=0;
printf("\n");
while(1){
scanf("%d",&arr[i]);
if(feof(stdin)){
break;
}
i++;
}
for(j=0;j<i;j++){
printf("%d ",arr[j]);
}
}