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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:54:18+00:00 2026-06-17T01:54:18+00:00

I am attempting to initialise an array to store segments of a snake for

  • 0

I am attempting to initialise an array to store segments of a snake for a snake game

the structure of the type ‘segment’ is defined here

 typedef struct snakeSegment {
    int x,y;
    }segment

Then I declare the structure of the snake (made up by segments)

struct snakeSegment snake[200];

The following code is the initialisation of the snake array

/*****************************************/
/* Create snake array of length snake_length */
void initSnake(segment snake[], int snake_length)
{
  int x = 50;
  int y = 50;
  snake[0].x= x;
  snake[0].y= y;
   for (int i = 1; i < 21; i++ ) 
  {
    snake[i].x= snake[i-1].x;
    snake[i].y= snake[i-1].y;
    x++;
  }
}

It reaches a problem whenever it gets to the main method and trys to run the initSnake() function

here is the main function

int main() { 
  initDevices();
  remainingSnakes = initGame();
  while ( remainingSnakes ) {
   // waitForStart();
    snakeInPlay= 1;
    currentDirection= 'N';
    initSnake(snake_length, snake );
    renderSnake(snake_length);
  }}

On the initSnake() line of code, it produces this error upon compiling:
of type “int” is incompatible with parameter of type “segment *”

I’ve asked around my peers and some seem to be having this issue. We would look for an alternative soloution but we were provided with a main function that was not to be greatly altered.
Any feedback would be greatly appreciated as I have no idea why I’m recieving this error. Thanks!

here is the main function we are meant to use to model against:

initialiseDevices();
remainingSnakes= initialiseGame();
while ( remainingSnakes ) {
waitForStart();
snakeInPlay= 1;
currentDirection= N;
snakeLength= 10;
initialiseSnake( snake, snakeLength );
renderSnake( snake, snakeLength );
while ( snakeInPlay ) {
newDirection= ReadBoardAngle();
currentDirection= moveSnake ( snake, newDirection, snakeLength );
snakeInPlay= testSnakeCollision( snake, snakeLength );
delay();
}
}
  • 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-17T01:54:19+00:00Added an answer on June 17, 2026 at 1:54 am

    This aren’t the parameters your function takes: initSnake(snake_length, snake );

    You probably meant initSnake(snake, snake_length);

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

Sidebar

Related Questions

I'm writing a game in Android/OpenGL and am attempting to separate my OpenGL (render)
I am attempting to create a basic Hangman program. It's an array of tags
I am attempting to create Conway's game of life in Java, and seem to
I'm attempting to initialise a string variable in C++, and the value is so
I'm attempting to initialize an array and add a chapter object to an array
im attempting to make a simple game where zombies spawn out randomly from the
Attempting to write a constructor for LinkedList to be initialised with an array of
Here's a good one to reflect on: http://en.wikipedia.org/wiki/Kakuro I'm attempting to make a solver
I am attempting to implement the AVFoundation example code found here in an Xcode
I'm attempting to do two things which are giving me problems: 1) typedef an

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.