I have a program which generates some files, when it has completed the console window requires the user to press a key (this isnt coded n, it seemingly is part of the the console).
Is there a way to turn this off i.e. so the program runs and closes down cleanly?
Code:
#include <stdio.h>
typedef struct {
char char3[3];
char newline;
}record;
int main(void) {
FILE *fpin3, *fpin6, *fpout;
int i;
const char *filename6="master_dic.txt"; //reminder to take the newline char #6
const char *filename3="3_character_append.txt";//leave the newline behind
char fileOut[]="dic1.txt";
record rec;
char char6[6];
unsigned long int count = 0;
fpin3 = fopen(filename3, "rt");
fpin6 = fopen(filename6, "rt");
if(fpin3 == NULL || fpin6 == NULL) {
printf("\nError opening input files");
return 1;
}
if((fpout =fopen(fileOut, "wb"))== NULL) {
printf("\nError opening output file");
return 1;
}
printf("\n\n\n");
for(i=0;i<5;i++) {
fread(&rec, sizeof(rec), 1, fpin3);
while(fread(char6, 6, 1, fpin6) >0) {
fwrite(char6, 5, 1, fpout); //ditto
fwrite(rec.char3, 3, 1, fpout); //fpout or stdout (for debug)
fwrite("\n", 1, 1, fpout);
++count;
//getch();
}
if(fileOut[3]=='5')
break;
rewind(fpin6);
fclose(fpout);
printf("\n closing file %s", fileOut);
fileOut[3]++; //increment the file number in the name
printf("\n opening file %s", fileOut);
if((fpout =fopen(fileOut, "wb"))== NULL) {
printf("\nError opening output file");
return 1;
}
}
/*fcloseall();*/
/*printf("\n\n %lu\n\t\t\t press enter when ready", count);*/
/*getchar();*/
/*i=getchar();*/
return 0;
}