Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8374169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:51:40+00:00 2026-06-09T14:51:40+00:00

I have poorly put together part of a program- code so far #include <windows.h>

  • 0

I have poorly put together part of a program- code so far

#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

#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(&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(&msg, NULL, 0, 0))
{
    TranslateMessage(&msg);
    DispatchMessage(&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"&Choose Balls");   
        AppendMenu(hMenuPopup, MF_STRING,  IDM_APP_EXIT,   L"&Exit");  
        AppendMenu(hMenu, MF_POPUP, (UINT_PTR)hMenuPopup,   L"&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 < 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

The error messages say i have an undeclared identifier and its in relation to my random number part,

case IDM_FILE_RUN:              
            {
                srand (time(NULL));
                for (int i = 0; i < 6; i++)
                    printf ("%i\n", (rand ()% 49) + 1);  

                return 0;
            }

Im unsure what i need to write and where i need to write it to fix it.

Thanks

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:51:42+00:00Added an answer on June 9, 2026 at 2:51 pm

    this may be a long-shot, but change your current for loops to look like this:

      int i;
      for (i = 0; i < 6; i++)
        ...
    

    it may be that your compiler doesn’t like declaring the variable inside the for (mine doesn’t unless I give it a special command line option)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# program that I poorly named when I first started it
We have had an issue with a block of code that responds poorly in
I have been assigned a project with a lot of poorly written code that
I have been given some poorly formatted data and need to pull numbers out
I have to connect to a poorly implemented server that only understands Content-Type (capital-T)
edit: my table schema below is poorly normalized as suggested and I have revamped
have written this little class, which generates a UUID every time an object of
I've decided to rewrite a database I have that is poorly normalized. I've created
I noticed that many websites, even Google and some banking sites, have poorly-written HTML
I have a poorly designed class in a 3rd-party JAR and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.