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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:35:12+00:00 2026-06-09T10:35:12+00:00

If my array is : char* String_Buffer = Hi my name is <&1> and

  • 0

If my array is :

char* String_Buffer = "Hi my name is <&1> and i have <&2> years old."
char* pos = strpbrk(String_buffer, "<");

Now pos is :

” <&1> and i have <&2> years old. “

But i need “Hi my name is”. How can do this?

  • 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-09T10:35:14+00:00Added an answer on June 9, 2026 at 10:35 am

    If you track start separately, you can “cut out” a section of the buffer:

    char *start = String_Buffer;
    char *end = strpbrk(String_Buffer, "<");
    
    if (end) {
        /* found it, allocate enough space for it and NUL */
        char *match = malloc(end - start + 1);
    
        /* copy and NUL terminate */
        strncpy(match, start, end - start);
        match[end - start] = '\0';
    
        printf("Previous tokens: %s\n", match);
        free(match);
    } else {
        /* no match */
    }
    

    To walk the buffer printing each token, you’ll simply hoist this into a loop:

    char *start = String_Buffer, *end, *match;
    
    while (start) {
        end = strpbrk(start, "<");
        if (!end) {
            printf("Last tokens: %s\n", start);
            break;
        } else if (end - start) {
            match = malloc(end - start + 1);
    
            /* copy and NUL terminate */
            strncpy(match, start, end - start);
            match[end - start] = '\0';
    
            printf("Tokens: %s\n", match);
            free(match);
    
            end++; /* walk past < */
        }
    
        /* Walk to > */
        start = strpbrk(end, ">");
        if (start) {
            match = malloc(start - end + 1); /* start > end */
            strncpy(match, end, start - end);
            match[start - end] = '\0';
    
            printf("Bracketed expression: %s\n", match);
            free(match);
            start++; /* walk past > */
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need an empty char array, but when i try do thing like this:
I currently have the dynamic array: char *myData[500][10]; //myData is the name of an
I have an array of char s and I need to extract subsets of
In my main file I have an array of character strings, char names[320][30], and
i have an char array b[20] which i want to write into a file
I have an char* array of binary data. It is binary media-stream encoded with
I have a char array in Python, which is read from a file e.g.
How can I convert the char array x to an integer 89 in the
I have a program to process very large files. Now I need to show
If I need to get a NUL-terminated char array out of a std::string in

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.