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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:46:50+00:00 2026-06-10T05:46:50+00:00

I got a char **function which returns obviously an Array of chars…. the problem

  • 0

I got a char **function which returns obviously an Array of chars…. the problem is that I don’t know how many strings are filled in the array …. char *data[size_of_data]; has been set at the first, but the function may not need all the array fields….

presume I got int size_of_data = 100 , but it just got 15 Strings …. if I want to break after the 15th String, which condition do I need in C … I got the data already in a char ** field and tried sth like….

 while(strcmp(data[i],'\0'))
{
    msg_send (session, para[0],data[i]);
    printf("------> %s \n",data[i]);
}   
  • 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-10T05:46:51+00:00Added an answer on June 10, 2026 at 5:46 am

    One thing you can do is to also provide the size of the array as an out parameter. Your function signature would look like this

    char ** function(size_t * num_strings); //num_strings is an out parameter
    

    Then you do something like so

    size_t nstrings = 0;
    char **strings = function(&nstrings);
    size_t i = 0;
    while (i < nstrings) {
        //do stuff
    }
    

    There’s an advantage to knowing the size, instead of just iterating until you hit a null pointer. Say you prepared an array of 100 char*. What if you use them all? There’s no null pointer, and you’ll have overrun your buffer. Of course, you could add an extra pointer at the end as a delimiter, but personally I like having the size.

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

Sidebar

Related Questions

I've got the following, which type-checks: p_int = liftA read (many (char ' ')
I would like to make function which detects/validates that a string got at least
I' ve got such a function static ssize_t read_mydevice(struct file *filp, char* buf, size_t
i got a question about unsigned char array. How can i store an integer
I got the following code, which converts a char[] to a byte[]: char[] cPwd
I've got a C# program that needs to pass a char buffer to an
I'm working on a section of code that has many possible failure points which
I have a dll which includes a function called ReadPort that reads data from
I have been struggling with a program that calls functions which return strings. I
I know I'm missing something easy here but I've got a templated member function

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.