c - Board game functions -


i have made program board game. problem function, fields transport player or forward. apparently thing did doesn't work.

int numbers() { int maxscore; int numbers[10]; maxscore = enter(); srand(time(null)); int nonumbers[3] = {0, 1, maxscore};  //to initialize scores there shouldn't badfield numbers[10] = rand() % maxscore + 1; if(numbers[10] == nonumbers[3]) {     numbers[10] = rand() % maxscore + 1; } return numbers;   }  int badfields = numbers(); if(score[i] == badfields)        {            printf("player %d. goes 5 fields backwards", playershown);            score[i] = score[i] - 5;            printf("this player in %d field", score[i]);        } 

somehow have repeat process of entering maximum score.

i won't directly answer "question" because there no "question" answered. others have pointed out in comments, need more specific , provide proper description of problem. can still provide following feedback:

it seems me don't quite understand arrays , indexing. example, line should give segmentation fault error, or @ least make comparison unknown value:

if(numbers[10] == nonumbers[3]) 

this because nonumbers array has 3 elements, , should addressed nonumbers[0], nonumbers[1] or nonumbers[2] (or, in general, weather vane put in comments, nonumbers[0] nonumbers[array_lenght-1]). nonumbers[3] access undefined position in memory. problem related this.

note neither me nor going review entire code find error. stated above, please more specific.

also, sure got rid of compiler errors? because further down code have uninitialized variable i. sure got rid of potentially nasty errors, open terminal (i'm assuming on linux) , use following command compile program:

gcc *.c -wall -wextra -o program 

then run with:

./program 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -