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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:49:47+00:00 2026-06-14T11:49:47+00:00

My function has this prototype: char[][100] toArray(char document[]); g++ on cygwin returns this error:

  • 0

My function has this prototype:

char[][100] toArray(char document[]);

g++ on cygwin returns this error:

Unable to resolve identifier toArray

How do I return an array of C-Strings?

  • 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-14T11:49:48+00:00Added an answer on June 14, 2026 at 11:49 am

    It’s impossible to return an array in C++. The closest you can do is return a pointer to a dynamically allocated block of strings.

    This is legal code

    typedef char str100[100];
    
    str100* toArray(char* document)
    {
        str100 *block = new str100[20];
        return block;
    }
    

    The typedef makes it a little easier to understand. If you don’t believe me here’s the same code without the typedef

    char (*toArray(char* document))[100]
    {
        char (*block)[100] = new char[20][100];
        return block;
    }
    

    This is meant to scare you.

    But although this code is legal it is also rubbish. You should be using std::vector<std::string>. Dynamically allocating memory is hard, much harder than using classes that do the work for you.

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

Sidebar

Related Questions

This figure again shows that every object has a prototype. Constructor function Foo also
this code produces 17 error C2995: function template has already been defined; there was
This has me stumped. The follow code returns ,,,,,,: <script type=text/javascript> $(function() { $('#listB').sortable({
Why can I do this: Array.prototype.foo = function() { this.splice(0, this.length); return this.concat([1,2,3]); }
On my Linux (and OS X) machines, the iconv() function has this prototype: size_t
Does this function has the same behavior that memset ? inline void SetZeroArray( void
I have a function B that has this declaration: public void B(Class<? extends C>
I've got a .js file that has this function in it: function showDialog(divID) {
I have a bash script that has this function in it: function start_vi() {
An exportable function has a struct as a one of the parameters. This DLL

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.