In this sample program it will create a random numbers in a given file in C.
programming projects , thesis and capstone projects, IT consulting
work, computer tutorials and web development work kindly contact me in the following email address for further details. If you want to advertise in my website kindly contact me also in my email address also. Thank you.
I am currently accepting programming work, it project, school
programming projects , thesis and capstone projects, IT consulting
work, computer tutorials and web development work kindly contact me in the following email address for further details. If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Program Listing
random.c
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void main( )
{
FILE *fp ;
char str [ 67 ] ;
int i, noofr, j ;
clrscr( ) ;
printf ( "Enter file name: " ) ;
scanf ( "%s", str ) ;
printf ( "Enter number of records: " ) ;
scanf ( "%d", &noofr ) ;
fp = fopen ( str, "wb" ) ;
if ( fp == NULL )
{
printf ( "Unable to create file." ) ;
getch( ) ;
exit ( 0 ) ;
}
randomize( ) ;
for ( i = 0 ; i < noofr ; i++ )
{
j = random ( 1000 ) ;
fwrite ( &j, sizeof ( int ), 1, fp ) ;
printf ( "%d\t", j ) ;
}
fclose ( fp ) ;
printf ( "\nFile is created. \nPress any key to continue." ) ;
getch( ) ;
}