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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:31:50+00:00 2026-06-01T08:31:50+00:00

I don’t understand why in the url_split function I can use a++ , but

  • 0

I don’t understand why in the url_split function I can use a++, but in the main function I can’t use key_value++, they have the same type…

void url_split(char *src, char **host, char *a[])    
{
    char const *p1 = "?";
    char const *p2 = "&";

    *host = strtok(src, p1);

    char *str;

    while((str = strtok(NULL, p2))) 
    {
        *a = str;
        a++;   
    }

    *a = str;
}

int main(int argc, char *argv[])    
{
    char *host;
    char *key_value[100];
    char url[] = "http://www.baidu.com/s?wd=linux&cl=3";

    url_split(url, &host, key_value);

    printf("host = %s\n", host);

    while(*key_value)
    {
        printf("key-value : %s\n", *key_value);
        key_value++; 
    }

    return 0;
}
  • 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-01T08:31:52+00:00Added an answer on June 1, 2026 at 8:31 am

    They actually don’t have the same type:

    • key_value is of type char *[100], an array of 100 char pointers.
    • a is actually of type char **, a pointer to a char*, not an array.

    When you pass key_value to url_split it decays to a char**, which is why key_value is a valid argument to the function and why you use char** as the type of a function argument that is intended to be an array of char*.

    The post-increment operator is incompatible with arrays, an array can’t be assigned a new value, but it works perfectly fine for pointers, since they can be assigned a new value. That’s why a++ is valid and key_value++ is not.

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

Sidebar

Related Questions

Don't ask me why but i can't use this method because I need to
Don't know why but I can't find a solution to this. I have 3
Don't they both have to convert to machine code at some point to execute
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't ask why but I have the requirement to draw a border around certain
DON'T ASK WHY but... I have a regex that needs to be case insensitive
I don't like Jackson. I want to use ajax but with Google Gson. So
Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face

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.