title: How to find the size of a string inside a function in C?
body: <p>Firstly before I explain, here is the code in C:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void printSize(char* str);
  
  int main()
  {
      char a[100] = "StackOverflow";
      printSize(a);
      return 0;
  }
  
  void printSize(char* str)
  {
      int n = sizeof(str) / sizeof(char);
      printf("%d" ,n);
  }
  </code></pre>
  
  <p>As you can already see, I am trying to get my function to print the value "100" as 100 is the size that I have allocated to my <code>char</code> array <code>a</code>. However I am getting 8 as my answer. Now I know why I am getting 8 here because it's printing the size of the pointer. So my question is, if I can't use this method to print out the value of "100" then how can I find out the memory allocated to <code>a</code> from inside the function?</p>
  
  <p>Thanks</p>