title: Random number gen- Undeclared identifier
body: <p>I have poorly put together part of a program- code so far</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define MAX_BUFF_SIZE 1024
  #define IDM_FILE_RUN 40001
  #define IDM_APP_EXIT 40002
  
  //Window Function
  LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
  
  
  int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, 
                 LPSTR lpszArgs, int nWinMode)
  {
  
  WNDCLASS wcls;
  HWND hwnd;
  MSG msg;
  
  // Name of window and window class
  LPCWSTR szWinName   = L"Threads Program";
  LPCWSTR szClassName = L"ThreadsProgram";
  
  
  wcls.hInstance = hThisInst;
  wcls.lpszClassName = szClassName;
  wcls.lpfnWndProc = WindowFunc;
  wcls.style = 0;
  wcls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  wcls.hCursor = LoadCursor(NULL, IDC_ARROW);
  wcls.lpszMenuName = NULL;
  wcls.cbClsExtra = 0;
  wcls.cbWndExtra = 0;
  wcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  
  // Register windows class
  if(!RegisterClass(&amp;wcls))
  {
      return 0;
  }
  
  // Create main window
  hwnd = CreateWindow(szClassName,
      szWinName,
      WS_OVERLAPPEDWINDOW,
      100,
      100,
      400,
      400,
      HWND_DESKTOP,
      NULL,
      hThisInst,
      NULL );
  
  // Show main window
  ShowWindow(hwnd, nWinMode);
  UpdateWindow(hwnd);
  
  // Message loop
  while(GetMessage(&amp;msg, NULL, 0, 0))
  {
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
  }
  return (int)msg.wParam;
  }
  
  
  
  LRESULT CALLBACK WindowFunc(HWND hMainWindow, UINT message, 
                          WPARAM wParam, LPARAM lParam)
  {
  static char textBuffer[MAX_BUFF_SIZE];
  static int nRead;
  
  
  switch(message)    
  {
  case WM_CREATE:
      {
          HMENU hMenu;
          HMENU hMenuPopup;
  
          // create menus
          hMenu = CreateMenu();
          hMenuPopup = CreateMenu();
  
          // populate menus
          AppendMenu(hMenuPopup, MF_STRING,  IDM_FILE_RUN,   L"&amp;Choose Balls");   
          AppendMenu(hMenuPopup, MF_STRING,  IDM_APP_EXIT,   L"&amp;Exit");  
          AppendMenu(hMenu, MF_POPUP, (UINT_PTR)hMenuPopup,   L"&amp;File");
  
          // attach menus to main window
          SetMenu(hMainWindow, hMenu);
      }
      break;
  case WM_COMMAND:
      {
          // Obey command
          switch(LOWORD(wParam))
          {
          case IDM_FILE_RUN:
  
              {
                  srand (time(NULL));
                  for (int i = 0; i &lt; 6; i++)
                      printf ("%i\n", (rand ()% 49) + 1);  
  
  
  
  
      return 0;
  
              }
              break;
          case IDM_APP_EXIT:
              SendMessage(hMainWindow, WM_CLOSE, 0, 0);
              break;
          }
      }
      break;
  case WM_DESTROY:
      PostQuitMessage(0);
      break;
  default:
      return DefWindowProc(hMainWindow, message, wParam, lParam);
  }
  return 0;
  }// Window function
  </code></pre>
  
  <p>The error messages say i have an undeclared identifier and its in relation to my random number part, </p>
  
  <pre><code>case IDM_FILE_RUN:              
              {
                  srand (time(NULL));
                  for (int i = 0; i &lt; 6; i++)
                      printf ("%i\n", (rand ()% 49) + 1);  
  
                  return 0;
              }
  </code></pre>
  
  <p>Im unsure what i need to write and where i need to write it to fix it. </p>
  
  <p>Thanks</p>
  
  <pre><code>Error   9   error C2059: syntax error : ')' 108 1
  Error   6   error C2065: 'i' : undeclared identifier    108 1
  Error   8   error C2065: 'i' : undeclared identifier    108 1
  Error   4   error C2143: syntax error : missing ')' before 'type'   108 1
  Error   2   error C2143: syntax error : missing ';' before 'type'   108 1
  Error   3   error C2143: syntax error : missing ';' before 'type'   108 1
  Error   5   error C2143: syntax error : missing ';' before 'type'   108 1
  </code></pre>