title: Why is can't num scan the intended value in c?
body: <p>I have to scan this file which partly contains</p>
  
  <pre><code>SNOL
  INTO num IS 8
  INTO res IS 9
  </code></pre>
  
  <p>and the output of the code below is </p>
  
  <pre><code>Program starts...
  Set value of num to 0
  Set value of res to 8
  input msg
  </code></pre>
  
  <p>which is wrong because <code>num</code> should be 8 and <code>res</code> should be 9</p>
  
  <p>why is it <code>num</code> scanning 0 instead of 8?</p>
  
  <p>and why doesn't the code work anymore if I assign number to num and number to res?</p>
  
  <pre><code>num = number;
  
  //Tokenizer functions//
  bool isLowerCase(const char *object)
  {
      int i;
      int len = strlen(object);
      for(i = 0; i &lt; len; i++) {
          if(object[i] &gt;= 'a' &amp;&amp; object[i] &lt;= 'z') {
              return true;
          }
      }
      return false;
  }
  //function to check if character is Float.
  bool objectFloat(const char* object) {
      //check if 1st character is a digit, if not then return false, 
      otherwise
          return true.
          if(!isdigit(object[0]))
              return false;
  
      // Check if the 2nd character to the last are digits or periods.
      // If not, return false otherwisereturn true
      int periods = 0;  //initialize how many periods in the object to zero
      int i;
      //if character is a period then increment periods.
      for(i = 1; i &lt; strlen(object); i++) {
          if(object[i] == '.') {
              periods++;
          }
          //return false if character is not a digit
          else if(!isdigit(object[i])) {
              return false;
          }
      }
      // return true if there is only one period.
      return periods == 1;
  }
  
  //function to check if character is a keyobject.
  bool isKeyobject(const char* object) {
      char keyobjects[11][11] = { "SNOL", "LONS", "INTO", "IS", "MULT", "BEG",
      "PRINT", "ADD", "SUB", "DIV", "MOD" };
  
      int i;
      for(i = 0; i &lt; 11; i++) {
          // Check if object is equal to keyobjects at index i
          // If yes, return true
          if(isLowerCase(object))
              return false;
          if(strcmp(object, keyobjects[i]) == 0) {
              return true;
          }
      }
      //object is not equal to any of the keyobjects so return false
      return false;
  }
  
  //Function to check if every character is an integer
  // If not, return false otherwise return true
  bool objectInt(const char* object) {
  
      int i;
      for(i = 0; i &lt; strlen(object); i++) {
          if(!isdigit(object[i])) return false;
      }
  
      return true;
  }
  
  bool objectIsVariable(const char* object) {
  
      // Check if alphanumeric character &amp; lower case
      // If not, return false
      int i;
  
      for(i = 0; i &lt; strlen(object); i++) {
  
          if(!isalnum(object[i]) &amp;&amp; !isLowerCase(object)) return false;
      }
      return true;
  }
  
  int main() {
  
      FILE *s_path = fopen("test.snol", "r");
  
      int number = 0;
      int num, res;
      if(isKeyobject(object) &amp;&amp; strcmp(object, IsitSNOL) == 0) {
          printf("Program starts...\n");
  
      }
      else if(isKeyobject(object) &amp;&amp; strcmp(object, IsitINTO) == 0) {
          printf("Set value of ");
      }
  
      if(objectInt(object)) {
          number = atoi(object);
      }
      else if(objectFloat(object)) {
          number = atof(object);
      }
      if(objectIsVariable(object) &amp;&amp; strcmp(object, IsitNum) == 0) {
          //if float
  
          printf("num to %d\n", number);
  
          num == number;
      }
      else if(objectIsVariable(object) &amp;&amp; strcmp(object, IsitRes) == 0) {
          //if float
          printf("res to %d\n", number);
          res == number;
      }
      else if(isKeyobject(object) &amp;&amp; strcmp(object, IsitBEG) == 0) {
          printf("input msg\n");
  
          scanf("%s", msg);
  
          fscanf(s_path, " %s", &amp;object);
          printf("INPUT(%s): %s\n", object, msg);
      }
  }
  } // END MAIN -----------------------------------//
  </code></pre>