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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:58:31+00:00 2026-05-25T16:58:31+00:00

im making a simple text game in c just for fun, but is having

  • 0

im making a simple text game in c just for fun, but is having some problems with structs and/or Visual Studio 2010. I’ve started a empty C++ project, but my main main file is main.c.

Here is the code:

int main()
{
    struct Player
    {
        char name[256];
        int sum;
    };

    struct Player player;
    strcpy(player.name, "John");
    player.sum = 0;

    struct Player cpu;
    strcpy(cpu.name, "Bob");
    cpu.sum = 0;

    printf("\n\n\n");
    system("PAUSE");
    return 0;
}

Now, the compiler is complaining alot! One of them:

Syntax error: missing ; before type (struct Player cpu line)

Rest is related to that cpu is not a struct and therefor non of the members gets recon by the compiler.

What have i done wrong with my struct?

  • 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-25T16:58:32+00:00Added an answer on May 25, 2026 at 4:58 pm

    In C, you have to declare all of your local variables first, at the beginning of the scope. You should move the struct Player cpu; declaration on the line right after struct Player player;

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

Sidebar

Related Questions

I'm making a simple 2 player game in XNA and started looking into saving
Hey so i'm making a simple text game using the pdCurses library and a
Suppose I have drawn simple text (say just the letter 'x') with some font
Iam making a simple app, I display pdf file with some text and images
I am currently making this text-based rpg game with a simple GUI. I was
I am making a simple game in order to learn a new language. I
If I'm making a simple grid based game, for example, I might have a
I'm making a simple 2D game for the iPhone. It's based on CrashLanding. so
I am making a simple text and script editor with code highlighting. For that
I am new to C++ and am making a simple text RPG, anyway, The

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.