c - Running a FIFO Simulation -
i trying run simulation program test fifo algorithm, program crashing. main, other functions not shown. can spot me problem.am not familiar using main argument[ int main(int argc, char *argv[])] have testing files in folder
int main(int argc, char *argv[]) { file *stream; if (argc != 3) { printf("the format is: pager file_name memory_size.\n"); //exit(1); } printf("file used %s, resident set size %d\n", argv[1], atoi(argv[2])); if ((stream = fopen(argv[1], "r")) == null) { perror("file open failed"); //exit(1); } mem_size = atoi(argv[2]); start_simulation(stream); fclose(stream); system("pause"); }
uncomment calls exit.
if (argc != 3) { // insufficient arguments passed..print error , exit. printf("the format is: pager file_name memory_size.\n"); exit(1); }
in case(exit commented) if not provide cmd-line arguments, argv[1]
null
, can cause crash when used in fopen
Comments
Post a Comment