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 8010457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:44:23+00:00 2026-06-04T18:44:23+00:00

I have to assign memory to a 3D array using a triple pointer. #include

  • 0

I have to assign memory to a 3D array using a triple pointer.

#include <stdio.h>
int main()
{
    int m=10,n=20,p=30;
    char ***z;
    z = (char***) malloc(sizeof(char**)*m*n*p);
    return 0;
}

Is this correct way of doing this?(I think what i am doing is incorrect.)

  • 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-06-04T18:44:24+00:00Added an answer on June 4, 2026 at 6:44 pm

    To completely allocate a 3D dynamic array you need to do something like the following:

    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        int m=10,n=20,p=30;
        char ***z;
    
        z = malloc(m * sizeof(char **));
        assert(z != NULL);
        for (i = 0; i < m; ++i)
        {
            z[i] = malloc(n * sizeof(char *));
            assert(z[i] != NULL);
            for (j = 0; j < n; ++j)
            {
                z[i][j] = malloc(p);
                assert(z[i][j] != NULL);
            }
        }
        return 0;
    }
    

    Freeing the data is left as an exercise for the reader.

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

Sidebar

Related Questions

I have a problem with using hash function. I have to assign some number(128
In this C code i have tried to assign pointer addresses of one variable
I have been trying to assign value to an object array that is defined
As I have so far learnt, a pointer is a place in memory (heap)
In C, in an Unix environment (Plan9), I have got an array as memory.
I have to assign permission on a folder and it's child folder and files
How to assign them to have tag: self.images = [NSMutableArray arrayWithObjects: @1.jpg,@2.jpg,@3.jpg,@4.jpg,@5.jpg,nil]; Whenever UIScrollView
I have the following code to assign a value to all the elements of
Somewhat often I have to build tables and assign to the table headers names
I have an click event that I want to assign to more than class.

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.