Homework Help (No warnings or Errors but program crashes)

This is a discussion on Homework Help (No warnings or Errors but program crashes) within the C Programming forums, part of the General Programming Boards category; Hey, I'm trying to build a mancala program in C but when it comes to the user's choice, they enter ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 07: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, 05: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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21