WindowsAPIが混じっているのですがご了承ください。
以下、strの宣言が悪いといってコンパイルエラーになります。

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
 switch (msg) {
   case WM_PAINT:
      HDC hdc;
      PAINTSTRUCT paint;
      char *str = "猫でもわかるプログラミング";

      hdc = BeginPaint(hWnd, &paint);
      TextOut(hdc, 10, 10, (LPCSTR)str, strlen(str));
      EndPaint(hWnd, &paint);
      break;

以下のように、{を追加するとエラーが出なくなります。どうして{が必要なのでしょうか?

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
 switch (msg) {
   case WM_PAINT:
   {                    ←★追加
      HDC hdc;
      PAINTSTRUCT paint;
      char *str = "猫でもわかるプログラミング";

      hdc = BeginPaint(hWnd, &paint);
      TextOut(hdc, 10, 10, (LPCSTR)str, strlen(str));
      EndPaint(hWnd, &paint);
      break;
   }                    ←★追加