Ok my friend i did what you told me as first step for the exercise... And it seems to wok fine but let me sent you the part i did to check it maybe i have done something wrong!!
Code:
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <time.h>
# define LIMIT 1000
void create_file(FILE *fp, int *Array,int N)
{
int i;
if ( fp == NULL )
{
printf ( "The file can not be created." ) ;
getch() ;
exit (0) ;
}
srand ( time(NULL) );
for ( i = 1; i < N; i++ )
{
Array[i] = rand()%LIMIT;
fprintf(fp, "%d ",Array[i]);
printf( "%d ", Array[i]) ;
}
}
void main()
{
char file_name[50];
int N;
FILE *fp;
printf("Please give name of the file you want to create: ");
scanf("%s", file_name);
printf("Please give how many numbers you want to put in the array: ");
scanf("%d", &N);
int Array[N];
fp = fopen(file_name, "w");
Array[0] = N;
fprintf(fp, "%d ", Array[0]);
printf("%d ", Array[0]);
create_file(fp,Array,N);
}
Can you help me now and with the other steps? Like sorting the array and put it in another file? I am so confused that's why i am asking you help.
Thank you.