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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:37:37+00:00 2026-05-21T18:37:37+00:00

In a previous question ( changing value from function ) I got help, which

  • 0

In a previous question (changing value from function) I got help, which lead me to the next problem:

I used a string split and then a simple copy

int Crawl :: splitUrl(char ***arr, int max_length, char *url)
{
   int idx=0;
   char * p;
   int i;

  p = strtok (url,"/"); // call the strtok with str as 1st arg for the 1st time.
    while (p != NULL && idx < max_length)
    {
       for (i=0;i<maxUrlSize-1 && p[i] != '\0';i++)
          (*arr)[idx][i] = p[i];
       for ( ; i< maxUrlSize-1;i++)
          (*arr)[idx][i] = '\0';

        printf("tmp[idx[%d]] %s  %d addr: %x\n",idx,(*arr)[idx],strlen(p),(*arr)[idx]);

        idx++;
        p = strtok (NULL, "/");
    }

The array is allocated:

 split_url = new char * [ maxUrlSplit ];
 printf("split_url %x\n",split_url);
 for (i=0;i<maxUrlSplit;i++)
  {
     split_url[ i ] = new char [ maxUrlSize ];
     printf("split_url[ %d ] %x\n",i,split_url[i]);
  }

and after the function i used a loop to get all elements in the arry. i printet it like

printf("add: %x %s %d\n",split_url[iarr], split_url[iarr], strlen(split_url[iarr]));

The address is always the same, but after the function runs there are no entries?

I run the function like

  int arr_size = crawl->splitUrl(&split_url,maxUrlSplit,url);

GDB and Valgrind don’t say anything.

  • 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-21T18:37:38+00:00Added an answer on May 21, 2026 at 6:37 pm

    After I made your code compilable, it worked “fine”, at least in the sense that it outputs the expected result. I make no comment on style or safety:

    const int maxUrlSplit = 10;
    const int maxUrlSize = 64;
    
    
    int splitUrl(char ***arr, int max_length, char *url)
    {
       int idx=0;
       char * p;
       int i;
    
      p = strtok (url,"/"); // call the strtok with str as 1st arg for the 1st time.
        while (p != NULL && idx < max_length)
        {
           for (i=0;i<maxUrlSize-1 && p[i] != '\0';i++)
              (*arr)[idx][i] = p[i];
           for ( ; i< maxUrlSize-1;i++)
              (*arr)[idx][i] = '\0';
    
            printf("tmp[idx[%d]] %s  %d addr: %x\n",idx,(*arr)[idx],strlen(p),(*arr)[idx]);
    
            idx++;
            p = strtok (NULL, "/");
        }
        return idx;
    }
    
    int main()
    {
        char url[] = "ant/bison/chimp";
    
        int i;
        char **split_url = new char * [ maxUrlSplit ];
        printf("split_url %x\n",split_url);
        for (i=0;i<maxUrlSplit;i++)
        {
            split_url[ i ] = new char [ maxUrlSize ];
            printf("split_url[ %d ] %x\n",i,split_url[i]);
        }
        int arr_size = splitUrl(&split_url,maxUrlSplit,url);
    
        for (i = 0; i < arr_size; i++)
        {
            printf("add: %x %s %d\n",split_url[i], split_url[i], strlen(split_url[i]));
        }
    }
    

    Output:

    split_url 2f1490
    split_url[ 0 ] 2f14e8
    split_url[ 1 ] 2f1558
    split_url[ 2 ] 2f15c8
    split_url[ 3 ] 2f1638
    split_url[ 4 ] 2f16a8
    split_url[ 5 ] 2f1718
    split_url[ 6 ] 2f1788
    split_url[ 7 ] 2f17f8
    split_url[ 8 ] 2f1868
    split_url[ 9 ] 2f18d8
    tmp[idx[0]] ant  3 addr: 2f14e8
    tmp[idx[1]] bison  5 addr: 2f1558
    tmp[idx[2]] chimp  5 addr: 2f15c8
    *************
    add: 2f14e8 ant 3
    add: 2f1558 bison 5
    add: 2f15c8 chimp 5
    

    Therefore, you must have some other issue in some other part of your code.

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

Sidebar

Related Questions

Continuing from my previous question , is there a comprehensive document that lists all
From a previous question I have seen that the CLR has workstation and server
From a previous question , I learn that Linq to SQL is not able
In a previous question one of the comments from Dr. Herbie on the accepted
This question is directly related to my previous question ASP.NET AJAX Is it possible
this question is an extension to a previous question i asked (and was answered).
This question is a follow up to my previous question about getting the HTML
Going back to my previous question on OCSP, does anybody know of reliable OCSP
In a previous question, I asked about various ORM libraries. It turns out Kohana
We determined in a previous question that many features of HTML SELECTs are not

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.