Need help printing 2D array

This is a discussion on Need help printing 2D array within the C Programming forums, part of the General Programming Boards category; I have most of the program working, I just dont know why the program stops working after this if statement ...

  1. #16
    Registered User
    Join Date
    Nov 2011
    Posts
    12
    I have most of the program working, I just dont know why the program stops working after this if statement
    Code:
     if(menu == 2)
                {
                    printf("What slot would you like to save this item to? 0-9\n");
                    scanf("%d", &slot);
                    printf("Please type in the name of the item you would like to enter\n");
                    scanf("%s", inv_items[slot][20]);
                }
    why does my program stop working after the second scanf statement?

  2. #17
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by schwindy22 View Post
    I have most of the program working, I just dont know why the program stops working after this if statement
    Code:
     if(menu == 2)
                {
                    printf("What slot would you like to save this item to? 0-9\n");
                    scanf("%d", &slot);
                    printf("Please type in the name of the item you would like to enter\n");
                    scanf("%s", inv_items[slot][20]);
                }
    why does my program stop working after the second scanf statement?
    line 6... scanf(" %19s", inv_items[slot]);

  3. #18
    Registered User
    Join Date
    Nov 2011
    Posts
    12
    still doesnt work

  4. #19
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by schwindy22 View Post
    still doesnt work
    Nice error description... post your code...

  5. #20
    Registered User
    Join Date
    Nov 2011
    Posts
    12
    i used the code from above, it doesnt work, the program times out. It just says program has stopped working

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing an array of strings until array == NULL
    By mikemhz in forum C Programming
    Replies: 10
    Last Post: 11-04-2011, 01:09 PM
  2. Printing an array
    By LoveTractor in forum C Programming
    Replies: 5
    Last Post: 11-21-2010, 03:26 PM
  3. Printing 2D Array
    By BB89 in forum C Programming
    Replies: 11
    Last Post: 11-16-2009, 04:33 AM
  4. printing array
    By Cpro in forum C++ Programming
    Replies: 7
    Last Post: 03-21-2008, 09:47 AM
  5. Printing a 2D array
    By Suchy in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2007, 03:53 PM

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