Defining buffer size correct "Stack around the variable String was corrupted"
<p>I have these two lines in my code:</p>

<pre><code>TCHAR String[400] = {0};
SendMessageW(hwnd, WM_GETTEXT,sizeof(String), (LPARAM)String);
</code></pre>

<p>When I use it that way I sometimes get a runtime error: "Stack around the variable String was corrupted"</p>

<p>When I use </p>

<pre><code>TCHAR String[400] = {0};
SendMessageW(hwnd, WM_GETTEXT,10, (LPARAM)String);
</code></pre>

<p>it works without problems. But I thought that the whole thing about using sizeof() is to make sure that there is no overflow problems.... Why is sizeof(String) not secure and what could I use instead??</p>

<p>Thanks! and have a nice day!</p>
