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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -