title: What does undeclared identifier and identifier is undefined mean? How to fix the error?
body: <pre><code>#include "stdafx.h"
  #include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  #define TIMEQUANTUM 1;
  #define MAXPROCTIME 100;
  
  
  struct SortList
  {
      int pid;
      int arrivalTime;
      int burstTime;
      SortList *nxt;
  };
  
  struct JobList {
      int pid;
      int ct_arrival;
      int ct_service;
      int vt_served;
      int vt_residence;
      int vt_wait;
      int vt_completion;
      JobList *nxt;
  };
  
  
  
  bool initJobList(JobList *&amp;,int *,int);
  bool deinit(JobList *&amp;);
  bool doFCFS (JobList *&amp;);
  bool doRR (JobList *&amp;);
  bool doSJF(JobList *&amp;, SortList *&amp;);
  bool doNPSJF (JobList *&amp;);
  bool doPSJF (JobList *&amp;);
  bool sortJob (JobList *&amp;, SortList *&amp;);
  
  int _tmain(int argc, _TCHAR* argv[])
  {
  
      JobList *ptrJobStart;
      // arrivaltime , bursttime
      int arrJobs[][2] = {
                          {0,7},
                          {2,4},
                          {4,1},
                          {5,4}
      };   
      SortList *ptrList;
      initJobList (ptrJobStart,(int *)&amp;arrJobs, (sizeof(arrJobs) / (sizeof(int)*2)));
      printf("\ndoFCFS\nCPU\t\tPROCESS\n");
         doFCFS (ptrJobStart);
      deinit(ptrJobStart);
  
      initJobList (ptrJobStart,(int *)&amp;arrJobs, (sizeof(arrJobs) / (sizeof(int)*2)));
      printf("\n\ndoSJF\nCPU\t\tPROCESS\n");
          doSJF(ptrJobStart, ptrList);
      deinit(ptrJobStart);
  
  
      initJobList (ptrJobStart,(int *)&amp;arrJobs, (sizeof(arrJobs) / (sizeof(int)*2)));
      printf("\ndoRR\nCPU\t\tPROCESS\n");
      doRR(ptrJobStart);
      deinit(ptrJobStart);
  
      initJobList (ptrJobStart,(int *)&amp;arrJobs, (sizeof(arrJobs) / (sizeof(int)*2)));
      printf("\ndoPSJF\nCPU\t\tPROCESS\n");
      doRR(ptrJobStart);
      deinit(ptrJobStart);
  
      getch();
      return 0;   
  }
  
  bool doRR(JobList *&amp;ptrJobStart)
  {
  
  
      if(ptrJob==NULL) return false;
      JobList *ptrJobStart, *tempJobList;
      ptrJobStart = ptrJob;
      int maxTime = MAXPROCTIME;
      int timeQuantum = TIMEQUANTUM;
      bool flag = false;
      ptrJobStart-&gt;vt_served = 0;
      for(int processTime = 0; (processTime &lt; maxTime) &amp;&amp; !flag ;)
      {
          //check if all jobs are finished
          flag = true;
          tempJobList = ptrJob;
          while(tempJobList!=NULL)
          {
              if(tempJobList-&gt;vt_served!=tempJobList-&gt;ct_service)
              {
                  flag = false;
              }
              tempJobList = tempJobList-&gt;nxt;
          }
      }
      //logic
      return true;
  }
  
  bool doSJF(JobList *&amp;ptrJobStart, SortList *&amp;ptrList)
  {
      if(ptrJobStart==NULL) return false;
      sortJob(ptrJobStart, ptrList); 
      doFCFS (ptrJobStart);
      return true;
  }
  
  bool sortJob (JobList *&amp;ptrJob, SortList *&amp;ptrList)
  {
      JobList *ptrJobStart = ptrJob;
      if(ptrJobStart==NULL) return false;
      int maxTime = MAXPROCTIME;
      SortList *newList;
      ptrList = NULL;
      for(; ptrJobStart!=NULL; ptrJobStart = ptrJobStart-&gt;nxt) // accumulate all arrival time = 0
      {
          if(ptrJobStart-&gt;ct_arrival==0)
          {
              if(ptrList==NULL)
              {
                  ptrList = new SortList;
                  ptrList-&gt;pid = ptrJobStart-&gt;pid;
                  ptrList-&gt;arrivalTime = ptrJobStart-&gt;ct_arrival;
                  ptrList-&gt;burstTime = ptrJobStart-&gt;ct_service;
                  ptrList-&gt;nxt = NULL;
              }
              else
              {
                  newList = new SortList;
                  newList-&gt;pid = ptrJobStart-&gt;pid;
                  newList-&gt;arrivalTime = ptrJobStart-&gt;ct_arrival;
                  newList-&gt;burstTime = ptrJobStart-&gt;ct_service;
                  newList-&gt;nxt = NULL;
                  ptrList-&gt;nxt = newList;
              }
          }
      }
      SortList *tempList;
      tempList = ptrList;
      for(int processTime = 1 ; processTime &lt; maxTime ; processTime++) // accumulate all burst time from 1 to 100
      {
          ptrJobStart = ptrJob;
          do
          {
              if((ptrJobStart-&gt;ct_arrival!=0) &amp;&amp; (processTime == ptrJobStart-&gt;ct_service))
              {
                  newList = new SortList;
                  newList-&gt;pid = ptrJobStart-&gt;pid;
                  newList-&gt;arrivalTime = ptrJobStart-&gt;ct_arrival;
                  newList-&gt;burstTime = ptrJobStart-&gt;ct_service;
                  newList-&gt;nxt = NULL;
                  tempList-&gt;nxt = newList;
                  tempList = tempList-&gt;nxt;
              }
              ptrJobStart = ptrJobStart-&gt;nxt;
          }while(ptrJobStart!=NULL);
      }
      //sort jobs
      ptrJobStart = ptrJob;
      JobList *tempJobList;
      tempJobList = ptrJobStart;
      for(; ptrList!=NULL; ptrList = ptrList-&gt;nxt)
      {
          tempJobList-&gt;pid = ptrList-&gt;pid;
          tempJobList-&gt;ct_arrival = ptrList-&gt;arrivalTime;
          tempJobList-&gt;ct_service = ptrList-&gt;burstTime;
          tempJobList = tempJobList-&gt;nxt;
      }
      return true;
  }
  
  
  bool doFCFS (JobList *&amp; ptrJob)
  {
      JobList *ptrJobStart = ptrJob;
      if(ptrJobStart==NULL) return false;
      int maxTime = MAXPROCTIME;
      ptrJobStart-&gt;vt_served = 0;
      for(int processTime = 0; processTime &lt; maxTime; processTime++)
      {
          if(ptrJobStart-&gt;vt_served!=ptrJobStart-&gt;ct_service)
          {
              ptrJobStart-&gt;vt_served+=1;
          }
          else
          {
              ptrJobStart-&gt;vt_completion = processTime;
              ptrJobStart-&gt;vt_residence = processTime - ptrJobStart-&gt;ct_arrival;
              ptrJobStart-&gt;vt_wait = processTime - ptrJobStart-&gt;vt_served;
              cout&lt;&lt;"\n/* vt_served:"&lt;&lt;ptrJobStart-&gt;vt_served&lt;&lt;"\tvt_residence:"&lt;&lt;ptrJobStart-&gt;vt_residence
                  &lt;&lt;"\tvt_wait:"&lt;&lt;ptrJobStart-&gt;vt_wait&lt;&lt;"\tvt_completion:"&lt;&lt;ptrJobStart-&gt;vt_completion&lt;&lt;" */";
              ptrJobStart = ptrJobStart-&gt;nxt;
              if(ptrJobStart==NULL) break;
              else
                  ptrJobStart-&gt;vt_served = 1;
          }
          cout&lt;&lt;"\n "&lt;&lt;processTime&lt;&lt;"\t&gt;&gt;\t P"&lt;&lt;ptrJobStart-&gt;pid;
      }
      return true;
  }
  
  
  bool deinit (JobList *&amp; ptrJobStart) {
  
      JobList *ptrJobDel = NULL;
      do {
  
          ptrJobDel = ptrJobStart;
          ptrJobStart = ptrJobStart-&gt;nxt;
          delete ptrJobDel;
      }while (ptrJobStart != NULL);
      return true;
  }
  
  
  bool initJobList(JobList*&amp; ptrJobStart,int *pJob,int nJobs){
  
      JobList * ptrJobs = NULL;
      int i;
      int j=1;
  
      for (i=0; i&lt;nJobs*2; i+=2) {
          if (ptrJobs == NULL) {
              ptrJobs = new JobList;
              memset(ptrJobs,0,sizeof(JobList));
              ptrJobStart = ptrJobs;
          }
          else {
              ptrJobs-&gt;nxt = new JobList;
              memset(ptrJobs-&gt;nxt,0,sizeof(JobList));
              ptrJobs = ptrJobs-&gt;nxt;
          }
          ptrJobs-&gt;ct_arrival = *(pJob+i);
          ptrJobs-&gt;ct_service = *(pJob+(i+1));
          ptrJobs-&gt;pid = j;
          ptrJobs-&gt;nxt = NULL;
          j++;
      }
      return true;
  </code></pre>
  
  <p>This code is for the scheduling algorithm. The shortest Job Next(SJN) / Shortest Job First (SJF) (which is the doSJN) is working. But when I included the doRR (do Round Robin), there are a lot of errors occuring.</p>
  
  <p>error C2065: 'ptrJob' : undeclared identifier
  error C2082: redefinition of formal parameter 'ptrJobStart
  error C2065: 'ptrJob' : undeclared identifier
  error C2065: 'ptrJob' : undeclared identifier
  see declaration of 'getch'</p>
  
  <p>How can i fix this?</p>