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 913591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:35:12+00:00 2026-05-15T17:35:12+00:00

Im trying to compile but im getting these errors: 1>.\item.cpp(123) : warning C4800: ‘int’

  • 0

Im trying to compile but im getting these errors:

1>.\item.cpp(123) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)

1>.\commands.cpp(1372) : error C2057: expected constant expression
1>.\commands.cpp(1372) : error C2466: cannot allocate an array of constant size 0
1>.\commands.cpp(1372) : error C2133: 'buffer' : unknown size

Line 123 item.cpp

if((bool)random_range(0, 1))

Line 1372 commands.cpp

if(money < changeSexPrice)
{
char buffer[70 + changeSexPrice];
sprintf(buffer, "You do not have enough money. You need %d gold coins to change your sex.", changeSexPrice);
player->sendCancel(buffer);
return false;
}

any idea?

  • 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-05-15T17:35:13+00:00Added an answer on May 15, 2026 at 5:35 pm

    Your problem is char buffer[70 + changeSexPrice];. win32 compilers need a constant expression when doing stack allocation.

    I’m not sure why you’re adding changeSexPrice as you are only using the buffer to print an int. I bet if you pick a something like char buffer[1024] then you will have more than enough for your needs.

    EDIT: Per the comments (which are very good).

    If you use a fixed size buffer of len 1024, use snprintf. In Visual Studio’s case, this is sprintf_s. Your code would change to:

    sprintf_s(buffer, 1024, "You don't have enough money ...", yourValueHere);
    

    Alternatively, Mark B presents an answer that removes the need for your own mem allocation as well.

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

Sidebar

Ask A Question

Stats

  • Questions 482k
  • Answers 482k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I figured out what it was with some investigation with… May 16, 2026 at 6:52 am
  • Editorial Team
    Editorial Team added an answer Make use of the Installer Class to add Custom installer… May 16, 2026 at 6:52 am
  • Editorial Team
    Editorial Team added an answer You can look at the Winamp SDK and should be… May 16, 2026 at 6:52 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.