Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5996535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:07:01+00:00 2026-05-23T00:07:01+00:00

My program is crashing. Basically, the data is not passing through the array for

  • 0

My program is crashing.

Basically, the data is not passing through the array for the menu choice and I am wondering if anyone could check it over and see where the problem is.

#include <stdio.h>
#include <stdlib.h>

void print_main_menu(char menu_items[5][10], int number_of_items) {
    int i;
    for (i = 0; i < number_of_items; i++) {
        printf("%s\n", menu_items[0][i]);
    }
}

int main () {
    char menu [5][10];
    menu [0][0] = "1 - Membership List";
    menu [0][1] = "2 - Waiting List";
    menu [0][2] = "3 - Committee List";
    menu [0][3] = "4 - Temporary List";
    menu [0][4] = "5 - Exit";

    /* 1 - Membership List */
    menu[1][0] = "1 - Whatever";
    menu[1][1] = "2 - Whatever";

    print_menu(menu, 5);

    getch();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:07:02+00:00Added an answer on May 23, 2026 at 12:07 am

    First off: you declared your function as print_main_menu but you are calling it as print_main but this should resolve into a compilation error.

    Secondly: you are using the two dimensional array incorrectly, apparantly you are using it as a two dimensional array of C strings, but you declared it as an array of characters.
    This would be the right declaration:

    char* menu [5][10];
    

    Lastly: a lot of the array indices are not initialized, which means that they can point anywhere which will most likely produce a segmentation fault and crash your application.

    EDIT: I’m also unsure if it is possible to pass an array to a function like you are doing it. It is most likely not a good idea to do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there is easy command in MATLAB which prevents program from crashing when it
The following program keeps crashing and I can't figure out what's wrong. It seems
In one RTOS, i'm debugging one issue which is, program is crashing one point
My program is crashing at the end of execution, and couldnt even see stack
My program is crashing every time I try to store a COM pointer into
Our Ad-hoc program is crashing on the following on one of our client's devices,
I'm having trouble with my program crashing. I get that Program.exe has stopped working
My program is crashing because my TextField is sending messages to its delegate after
My program is crashing as a result of the runtime sending isEqualToString: to a
My program is crashing and I'm having a hard time wrapping my head around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.