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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:04+00:00 2026-05-26T19:02:04+00:00

I’m puzzled as to how the header, return and call would look. This is

  • 0

I’m puzzled as to how the header, return and call would look.

This is what gave me the error “Wrong pointer type”

        int **CreatesArray (int r,int c)
    {
        int table [r][c];
        printf ("Enter clause orientations.\n");
        for (int i = 0; i<r;i++)
            {
                for (int j = 0;j<c;j++)
                    {
                        scanf ("%d",&table[i][j]);
                    }
            }
        return table;
    }

Function call from main:

int **tableaux;

tableaux = CreatesArray(ROWS,COLS);

Why is this not the correct way of doing it?

NOTE: Will post TableCreator shortly

  • 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-26T19:02:05+00:00Added an answer on May 26, 2026 at 7:02 pm

    Your function is a little off. For one thing, you’re creating the two-dimensional array table[r][c] on the stack, and you can’t return stack-allocated arrays from functions in C.

    You will have to allocate the table on the heap, and return that. Here’s an example:

    #include <stdio.h>
    #include <stdlib.h>
    
    int** create_table (int r,int c)
    {
        // malloc the row pointers
        // in case you're wondering what I'm doing with sizeof(*table),
        // it's getting the size of *table which is the size of the 
        // underlying pointer type, because we will be allocating the 
        // column pointers. C allows this seemingly weird syntax 
        // because sizeof does not evaluate its operand.
    
        int **table = malloc(r * sizeof(*table));
    
        // for each row pointer, allocate 'c' column pointers
        for (int i = 0; i < r; ++i) {
            // sizeof(**table) gets the underlying type of a double-dereference,
            // which is sizeof(int) in this case.
            table[i] = malloc(c * sizeof(**table));
        }
    
        // read into your table
        for (int row = 0; row < r; ++row) {
            for (int col = 0; col < c; ++col) {
                printf("Enter orientation for table[%d][%d]: ", row, col);
                scanf ("%d",&table[0][0]);
            }
        }
    
        return table;
    }
    
    int main() {
        int row = 10;
        int col = 10;
        int **table = create_table(row, col);
    
        for (int r = 0; r < row; ++r) {
            for (int c = 0; c < col; ++c) {
                printf("table[%d][%d]: %d\n", r, c, table[r][c]);
            }
        }
    
        // free all the column pointers
        for (int i = 0; i < row; ++i) {
            free(table[i]);
        }
    
        // free the row pointers
        free(table);
    
        return 0;
    }
    

    If you don’t know about C memory allocation and management, read some stuff here:

    • Dynamically allocating multidimensional arrays in C
    • C Memory Allocation
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6

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.