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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:19:27+00:00 2026-06-07T03:19:27+00:00

For example if the string is: XYZ ::[1][20 BB EC 45 40 C8 97

  • 0

For example if the string is:

XYZ ::[1][20 BB EC 45 40 C8 97 20 84 8B 10]

The output should be:

20 BB EC 45 40 C8 97 20 84 8B 10

int main()
{
    char input = "XYZ ::[1][20 BB EC 45 40 C8 97 20 84 8B 10]";
    char output[500];
    // what to write here so that i can get the desired output as: 
    // output = "20 BB EC 45 40 C8 97 20 84 8B 10"
    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-07T03:19:29+00:00Added an answer on June 7, 2026 at 3:19 am

    In C, you could do this with a scanset conversion (though it’s a bit RE-like, so the syntax gets a bit strange):

    sscanf(input, "[%*[^]]][%[^]]]", second_string);
    

    In case you’re wondering how that works, the first [ matches an open bracket literally. Then you have a scanset, which looks like %[allowed_chars] or %[^not_allowed_chars]. In this case, you’re scanning up to the first ], so it’s %[^]]. In the first one, we have a * between the % and the rest of the conversion specification, which means sscanf will try to match that pattern, but ignore it — not assign the result to anything. That’s followed by a ] that gets matched literally.

    Then we repeat essentially the same thing over again, but without the *, so the second data that’s matched by this conversion gets assigned to second_string.

    With the typo fixed and a bit of extra code added to skip over the initial XYZ ::, working (tested) code looks like this:

    #include <stdio.h>
    
    int main() { 
        char *input = "XYZ ::[1][20 BB EC 45 40 C8 97 20 84 8B 10]";
    
        char second_string[64];
        sscanf(input, "%*[^[][%*[^]]][%[^]]]", second_string);
    
        printf("content: %s\n", second_string);
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for example the string is my name is xyz(25) i want to get 25
For example I have a string <abc=xyz> abc can change and so does the
An example string: AB-XYZ-123 Where: AB : Any two capital alphabets only, no symbol,
void main() { int xyz = 123; // original value { // code block
Is it possible to convert alphabetical string into int in C#? For example string
My understanding is that literals are automatically interend. Let's take below code example. string
How can I remove a substring from a string using Perl? For example, $URL
Question 1: For example, ... ab'cd ... 'abcd' ... It should get ab'cd and
I've two string arrays. For example A = {ABC, XYZ, MNO} and B =
Example string $string = 'how-do-i-retrieve-last-word' $string = 'how-do-i-retrieve-last-word-2' $string = 'how-do-i retrieve-last word-123' $string

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.