Thread: Need help printing 2D array

  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

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, 04:26 PM
  3. Printing 2D Array
    By BB89 in forum C Programming
    Replies: 11
    Last Post: 11-16-2009, 05: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, 04:53 PM

Tags for this Thread