Thank you for all advices, I solved the problem and it is function call overflow. Yes, the code is really a mass and ugly so I managed to clean it up, I will replace the code with the new one here.
This is my final year project, I am trying to write a c program that reads multiple .c codes and modifying it, then complie and running it and finally reads the ouput.txt and comparing it with ans.txt.
I am encountering a weird problem, the code complies with no warning, but when I tried to run it at command line, it does nothing but shows a empty line.
After few testing, I find that if I comment one line of code, that is a call of fread function, the program will works fine. I do not understand the reason and how to solve it.
when the program works, it should be like this in command line:
C:\batch.exe
Welcome to the batch system
(Starts processing)...
However, I am getting this now:
C:\batch.exe
C:\
here is my the main part of my code:
int main(){
int agu = 1, fim; // agument for controlling the program
int filesize[256]; //used on sacn()
int num = 0; // stores total number of files detected
char sdir[] = "./input/", filter[]= "*.c", filename[128][256]; //Varibies used on auto-detecting
struct _finddata_t c_file; //Varibies used on auto-detecting
long hFile; //Varibies used on auto-detecting
printf("\nWelcome to the my system");
Sleep(1000);
printf("\nPlease put all files on input folder in order to let this program read it");
Sleep(1000);
fflush(stdout);
do{
_chdir(sdir);
hFile = _findfirst(filter, &c_file);
if (hFile != -1)
{
num = 0;
do{
sprintf(filename[num], "%s", c_file.name);
printf("\n%s\n", filename[num]);
num++;
} while (_findnext(hFile, &c_file) == 0);
}
else{
printf("\nNo .c files found in input folder.\nThe Program will be exit after 5 second.");
Sleep(5000);
return 0;
}
_chdir("..");
printf("\nTotal %d file(s) will be imported", num);
printf("\nConfirm ? (Y / N)\nYou Can Also Press Ctrl + C or Enter Q to Terminate this Program.");
do {
fim = getchar();
putchar(fim);
if (fim == 'Y' || fim == 'y')
agu = 0;
else if (fim == 'Q' || fim == 'q')
return 0;
else agu = 1;
} while (fim != 'y' && fim != 'Y' && fim != 'N' && fim != 'n');
}while(agu==1);
mod(filename,sdir,num); // modify , compile and run the code
printf("\nEnter Y to Start Result Comparing, or Enter N to Exit This Program.(Y/N)");
fim = 'a';
do {
fim = getchar();
putchar(fim);
if (fim == 'Y' || fim == 'y')
agu = 0;
else agu = 1;
} while (fim != 'y' && fim != 'Y' && fim != 'N' && fim != 'n');
if (agu == 0){ //Resulting Comparing Function
comp();
}
else{
printf("\nThank You For Using This Software, This Program will be terminated.");
}
return 0;
}