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

  • SEARCH
  • Home
  • 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 7504089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:27:18+00:00 2026-05-29T21:27:18+00:00

I need an array which I can access from different methods, I have to

  • 0

I need an array which I can access from different methods, I have to allocate this array in main() and then let other functions like foo() get access to this array.

This question helped me with allocating the array: defining a 2D array with malloc and modifying it
I’m defining the array like this:
char(*array)[100] = malloc((sizeof *array) * 25200);
And I’m doing this in main()
I can store 25200 strings in this array an access them by array[1]

Is it now possible to access this array from different methods, how can I do that?

  • 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-29T21:27:21+00:00Added an answer on May 29, 2026 at 9:27 pm

    With this declaration:

    char (*array)[100] = malloc((sizeof *array) * 25200);
    

    You can have a function foo:

    void foo(char array[][100])
    {
        array[42][31] = 'A';  // you can access characters elements this way
        strcpy(array[10], "Hello world\n");  // you can copy a string this way
    }
    

    and you can call foo this way:

    foo(array);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array which i need to sort its elements by occurrence then
I have an application in which I need to pass an array from C#
I have an array Items which has 10 elements. I need to remove the
I need an array to hold member-function-pointers of different classes. How can I define
In this I need C++ array class template, which is fixed-size, stack-based and doesn't
I have created a custom button called ModuleUIButton which inherits from UIButton . This
I have a multi-dimensional array of databases, which was generated from my server: //
I got an array which contains signed int data, i need to convert each
I need to create an array of images in which, every time I tap,
I've got a 1-based array of four items which I need to traverse. For

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.