there're input1.txt command1.txt given files
subject asking for create a result1.txt file with the data from the given files.
there's no any bug while compile,
but when running the program windows system pop out error report that:
***.exe has encountered a problem and needs to close.
We are sorry for the inconvenience.
i would like to know which problem of this program meet and which part should be debug.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <cctype>
using namespace std;
int main()
{
FILE * finput;
FILE * fcommand;
FILE * crfile;
// ifstream finput;
// ifstream fcommand;
// ifstream crfile;
int max_terms = 10;
int q = 0;
char temp;
typedef struct pac{
char strinput[32];
};
typedef struct com{
char strcommand[24];
};
struct pac packe[max_terms];
struct com comm[max_terms];
int timeslot1[max_terms];
int timeslot2[max_terms];
finput = fopen("input1.txt","r");
fcommand = fopen("command1.txt","r");
crfile = fopen("result1.txt","w");
// finput.open("input1.txt");
// fcommand.open("command1.txt");
// ofstream crfile("result1.txt");
for(int i=0; i<max_terms;i++){
fscanf(finput,"%d",timeslot1[i]);
fgets(packe[q].strinput, 32, finput);
if(packe[q].strinput[0]!='\n') q++;
fscanf(fcommand,"%d",timeslot2[i]);
fgets(comm[i].strcommand, 24, fcommand);
cout<<packe[q].strinput<<endl<<comm[i].strcommand<<endl;
}
fclose(finput);
fclose(fcommand);
fclose(crfile);
// finput.close();
// fcommand.close();
// crfile.close();
cout<<"Press enter to continue...";
cin.get();
}
thank you.