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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:20:34+00:00 2026-05-14T22:20:34+00:00

I have a semi xml formatted file that contains line with the following format:

  • 0

I have a semi xml formatted file that contains line with the following format:

<param name="Distance" value="1000Km" />

The first char in the string is usually a TAB or spaces.
I’ve been using the following to try to parse the two strings out (from name and value):

if(sscanf(lineread, "\t<param name=\"%s\" value=\"%s\" />", name, value) == 1)
{
    //do something
}

name and value are char*

Now, the result is always the same: name gets parse (I need to remove the quotes) and name is always empty.
What am I doing wrong?

Thanks, code is appreciated.

Jess.

  • 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-14T22:20:35+00:00Added an answer on May 14, 2026 at 10:20 pm

    As usual, a scanset is probably your best answer:

    sscanf(lineread, "%*[^\"]\"%[^\"]\"%*[^\"]\"%[^\"]\"", name, value);
    

    Of course, for real code you also want to limit the lengths of the conversions:

    #include <stdio.h>
    
    int main() { 
        char lineread[] = "<param name=\"Distance\" value=\"1000Km\" />";   
        char name[256], value[256];
    
        sscanf(lineread, "%*[^\"]\"%255[^\"]\"%*[^\"]\"%255[^\"]\"", name, value);
    
        printf("%s\t%s", name, value);
        return 0;
    }
    

    Edti: BTW, sscanf returns the number of successful conversions, so in your original code, you probably wanted to compare to 2 instead of 1.

    Edit2: This much: %*[^\"]\" means “read and ignore characters other than a quote mark”, then read and skip across a quote mark. The next %255[^\"]\" means “read up to 255 characters other than a quote mark, then read and skip across a quote mark. That whole pattern is then repeated to read the second string.

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

Sidebar

Related Questions

Okay so i have a semi weridish problem with re.sub. Take the following code:
Have a network location that shows paths in the 8.3 short format. I need
I'm looking for information extraction libraries where I can have semi structured information that
I have a semi-working example that you can look at. This appears to work
I have a semi-melted data frame that looks like this: head(final_melt) Group Source variable
Windows 7 windows naturally have a semi-transparent header. What I just realized is that
We have semi-complicated expressions in the format: 25 + [Variable1] > [Variable2] We need
Database tables are created successfully by <property name=hibernate.hbm2ddl.auto value=create/> in persistence.xml, however each time
I have a semi-large web application that we run locally and I need to
I have a (semi)RESTful web service that I'm working on written in c++. We

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.