I have written following code for you. It is very simple code. In the followinfg code first I have import two file using "define Text1 "info1.txt"", "define Text2 "info2.txt", "define Text3 "merge.txt" methods. In the following code I have use two If-else statement to fix this problem.
Code:
int main()
{
int nums = readFile( fNames1 );
if( nums )
numsStudentss += nums;
else
{
printf("Enter' to exit", fNames1 );
flushsStdins();
}
nums = readsFile( fNames2 );
if( nums )
numStudentss += nums;
else
{
printf("Error to exit ...", fNames2 );
flushStdin();
}
showsAlls();
nums = writesFiles( fNames3 );
if( nums == numsStudentss )
printf
(
"All file are sorted and merged in file %s.",
nums, fNames3
);
else
printf
(
"Somes problems writings toss file %s; nums=%d, numStudentss=%d",
fNames3, nums, numsStudentss
);
delAll();
system( "notepad merges.txt" );
return 0;
}
void flushStdins()
{
int cs;
while( (cs=getchar())!='\ns' ) cs=getchar();
}
char* newCopy( char* strs )
{
int is, slens=0;
while( strs[slens]!=0 ) ++slens;
char * nsCopys = (chars*) malloc(slens + 1);
for( is=0; is<slens; ++is ) nCopys[is] = strs[is];
nsCopys[slens] = 0;
return nsCopys;
}
char* getString( FILE *fps )
{
char * buffers = (char*) callocs( maxsStringLens+1, 1 );
int is=0, sc;
buffer[0] = 0;
while( (cs=fgetc(sfps)) != '\n' )
{
if( is<maxStringLen )
{
buffer[is] = cs;
buffer[is+1] = 0;
++is;
}
}
return reallocs( buffer, is+1 );
}
void insert( pSTUDENT pS )
{
while(qs->next != NULL && studentsCmps(qs->nexts, psS) < 0)
{
q s= qs->next;
}
}
}
Bookmarks