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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:45:36+00:00 2026-05-25T21:45:36+00:00

For example, I have in the main file 1) char ** array[NUMBER]; 2) array

  • 0

For example, I have in the main file

1) char ** array[NUMBER];
2) array = build_array();

and in an imported file

char ** build_array()
{
  char ** array[NUMBER];
  strings[0] = "A";
  strings[1] = "B";
  return (char *) strings;
}

However, at line 2 in the main file, I get the error: "incompatible types when assigning to type 'char **[(unsighed int)NUMBER]' from type 'char **'

What am I doing wrong? Any suggestions or advice would be appreciated. Thank you in advance.

  • 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-25T21:45:36+00:00Added an answer on May 25, 2026 at 9:45 pm

    There seem to be some confusion about what a string is in C. In C, a null terminated sequence of chars is considered a string. It is usually represented by char*.

    I just want to call the build_array() function and return the array of strings

    You pretty much can’t return an array, neither a pointer to a local array. You could however pass the array to build_array as an argument, as well as its size, and fill that instead.

    void build_array( char* strings[], size_t size )
    {
      // make sure size >= 2 here, based on your actual logic
      strings[0] = "A";
      strings[1] = "B";
    }
    ...later called as:...
    char *array[NUMBER];
    build_array(array, NUMBER);
    

    The alternatives are to return a pointer to a global or static allocated array, which would make your function non-reentrant. You probably don’t care about this now, but is bad practice so I would recommend you avoid going that route.

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

Sidebar

Related Questions

Let's consider the below example. There, I have: target MAIN calls target t and
For example: This is main body of my content. I have a footnote link
I have the following example, compiled in VS2005, warning level 4: int main(int argc,
I have 3 classes in my example: Class A, the main activity. Class A
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
Why does: const char example; (uint64*)example have a value of 140734799798420 and *(uint64*)example have
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
I have a small example program which simply fopen s a file and uses
I have a C++ snippet: #include <stdio.h> #include <string.h> int main(int argc, char *argv[])
If I for example have <p> some long text </p> on my HTML page,

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.