Master Menu - Links the Master Page
Columns . . . : Edit AMOTT/SRCFILE
SEU==>_______________________________________________________ A07
FMT C* .....C*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
/* Project 7 - Merging data
** Reads in a file containing two data sets and merges them into numerical
** order and writes the merged output to a file named Shitout.dat
**
** Written by: Worthley ©
** Date: April 27, 1999
*/
#include
int main ( void )
{
FILE *input_file ;
FILE *merged ;
int id[35] ;
char cc[35] ;
int x = 0 ;
int c ;
int id2 ;
char cc2 ;
int z = 0 ;
char shit ;
merged = fopen("l:\Shitout.dat", "w") ;
input_file = fopen("l:\Employee.dat", "r") ;
if(input_file == NULL)
{
printf("File not found.\n") ;
return 1 ;
}
fscanf(input_file, "%i", &id[x]) ;
fscanf(input_file, "%c", &shit) ;
while(id[x] > 0)
{
fscanf(input_file, "%c", &cc[x]) ;
x++ ;
fscanf(input_file, "%i", &id[x]) ;
fscanf(input_file, "%c", &shit) ;
}
z = x ;
x = 0 ;
c = fscanf(input_file, "%i %c", &id2, &cc2) ;
while(c != EOF)
{
if(id2 < id[x] || x >= z)
{
fprintf(merged,"%i %c 2\n", id2, cc2) ;
c = fscanf(input_file, "%i %c", &id2, &cc2) ;
}
else if(id[x] < id2)
{
fprintf(merged,"%i %c 1\n", id[x], cc[x]) ;
x++ ;
}
}
fclose(input_file) ;
fclose(merged) ;
return 0 ;
}
/* End of Source */
Copyright ©1998 - 2001 J. Browning - All rights reserved.
Master Menu - Links the Master Page