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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:13:44+00:00 2026-06-12T15:13:44+00:00

I am running my code on compilr.com and am using C as my language.

  • 0

I am running my code on compilr.com and am using C as my language. I am trying to make a simple game where you have an inventory and start out with $100. You gain money by doing jobs secretly for other players. But, I’m getting an error message that says, “Invalid initializer.” What is this and how do I fix it? here is my code:

#include<stdio.h>

int main()
{
    int player_cash[][3] = 100;
    int player[3];
    int job[][100] = {
        "Text me the address of player1",
        "I'll donate $100 to the your funds, if you steal the gold from player2 for me"
    };
            if (player_cash[1] > 5);
                do job[0]
        else if(player_cash[1]<5);

        return 0;
}
  • 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-12T15:13:45+00:00Added an answer on June 12, 2026 at 3:13 pm
     int player_cash[][3] = 100;
    

    You declare a 2D array of ints, then try to initialize it with a single int.
    Correct syntax is

     int player_cash[][3] = 
     { 
       {100}
     };
    

    although int player_cash[][3] = { 100 }; will work fine too, just less stylistically correct.

    int job[][100] = { "Text me 
    

    ints are integers, they are not strings. So that code doesn’t even make sense.

    Also, make a habit of always using {} after an if-statement.

    if (player_cash[1] > 5);
     do job[0]
    

    will, because of the semi-colon, be treated as if you had written

    if (player_cash[1] > 5)
    {}
    do job[0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built ffmpeg for Android using the code and method described at https://github.com/halfninja/android-ffmpeg-x264
While running code in production, I don't have to interact with the Ember.js runloop
I have a thread in my application that is running code that can potentially
I'm following this http://www.codeproject.com/Articles/10020/Using-managed-code-in-an-unmanaged-application The example consist of 3 binaries: C# code C++/CLI code
I'm attempting to following the tutorials found here: http://www.ifadey.com/2010/06/crud-using-jquery-and-codeigniter/ My code is updated to
I have been running the python code below for approx a year now. But
I'm trying to run the sample code from this Sun tutorial: http://download.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html I've copied
I am using codepad.org and ideone.com for sharing my php code with others and
I am attempting to compile some code, but am running into some problems that
I'm running Ubuntu to compile a set of code which requires python 2.4. How

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.