Thread: Homework Help (No warnings or Errors but program crashes)

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    14

    Homework Help (No warnings or Errors but program crashes)

    Hey, I'm trying to build a mancala program in C but when it comes to the user's choice, they enter their desired number but then the program crashes. Something odd with the switch function I presume. Help?[code]#includeint gamestart(int x[]);int board(int x[]);//int choose(int choiceA, int x[]);int check(int x[]);int main(){ int i; int x[7]; int c = 0; gamestart(x); while(1){ board(x); check(x); printf("Choose one of the pits\n"); printf("For Pit 1: 1 For Pit 2: 2 For Pit 3: 3\n\n"); scanf_s("%d",c); //choose(choiceA,x); switch(c){ case (1): for(i=3;i

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Edit your post, and make sure you post all your code in code tags.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    14
    Sorry, turns out it was a rookie mistake, I was missing a "&" in the scanf function. Whoops.A new problem has arisen though, when using the switch function, the wrong side seems to increment according to which number was chosen. I know not why.Also, I can't seem to post code on this site without it being cut off. Sorry for the inconvenience, IGNORE ME!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors and warnings
    By _arjun in forum C Programming
    Replies: 2
    Last Post: 11-14-2011, 08:29 AM
  2. Replies: 16
    Last Post: 08-02-2011, 12:30 PM
  3. program crashing despite no errors and warnings
    By yohanevindra in forum C Programming
    Replies: 10
    Last Post: 09-07-2010, 10:40 PM
  4. How do I fix these annoying warnings and errors?
    By zyphirr in forum C Programming
    Replies: 18
    Last Post: 11-12-2008, 06:19 PM
  5. Definitions for gcc errors and warnings?
    By cpjust in forum C Programming
    Replies: 12
    Last Post: 10-04-2007, 09:18 AM

Tags for this Thread