title: C - unable to edit or print char array
body: <p>Newbie question here... How am I supposed to properly deal with mutable char arrays that represent strings when I'm in a function? I'm doing this</p>
  
  <pre><code>char temp[BASE10LENGTH_DEGREE_DECIMALS+1]; //aka length of 7
  memset(temp, 0, sizeof(temp));
  </code></pre>
  
  <p>As you can see, it has that null-terminator in there. But if I do something like this</p>
  
  <pre><code>temp[i] = '1'; //when i = 0
  </code></pre>
  
  <p>then call atoi() on temp, I get 0. EDIT 2: No I don't! But I still can't print it in the debugger.</p>
  
  <p>Also, if I look at the debugger, temp does not expand into an array, and using lldb's print feature on it gives me this</p>
  
  <pre><code>(lldb) print temp
  error: incomplete type 'char []' where a complete type is required
  error: 1 errors parsing expression
  </code></pre>
  
  <p>It works if I use a char* and malloc it, but that's not what I want to do. I want just a char array. What am I doing wrong?</p>
  
  <p>EDIT: Here's the whole method. input is "3, 4, 5", and len is 7:
  EDIT 2: Actually, the problem with atoi was because I messed up those if statements by putting in less than 9 and greater than 0 instead of less than '9' and greater than '0'... Careless error.</p>
  
  <pre><code>struct Coordinates{
  unsigned int longitude;
  unsigned int latitude;
  unsigned short altitude;
  };
  
  struct Coordinates* getCoordinatesFromString(char* input, int len){ 
  struct Coordinates* ret = malloc(sizeof(struct Coordinates));
  
  char temp[BASE10LENGTH_DEGREE_DECIMALS+1];
  memset(temp, '\0', sizeof(temp));
  int i = 0; int i2 = 0; char currentChar;
  while (input[i]!=','){
      if (i&gt;=len)
          return NULL; //out of bounds error
      currentChar = input[i];
      if ((currentChar&gt;=0 &amp;&amp; currentChar&lt;=9) || currentChar=='.') temp[i2] = currentChar;
      i++;
      i2++;
  }
  ret-&gt;latitude = atoi(temp);
  memset(temp, 0, sizeof(temp));
  i++; i2 = 0;
  while (input[i]!=','){
      if (i&gt;=len)
          return NULL; //out of bounds error
      currentChar = input[i];
      if ((currentChar&gt;=0 &amp;&amp; currentChar&lt;=9) || currentChar=='.') temp[i2] = currentChar;
      i++;
      i2++;
  }
  ret-&gt;longitude = atoi(temp); //keeps giving me zero
  memset(temp, 0, sizeof(temp));
  i++; i2 = 0;
  while (input[i]!=','){
      if (i&gt;=len)
          break;
      currentChar = input[i];
      if ((currentChar&gt;=0 &amp;&amp; currentChar&lt;=9) || currentChar=='.') temp[i2] = currentChar;
      i++;
      i2++;
  }
  ret-&gt;altitude = atoi(temp);
  memset(temp, 0, sizeof(temp));
  
  return ret;
  }
  </code></pre>