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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:19:04+00:00 2026-05-27T09:19:04+00:00

gcc 4.6.1 c89 I have a string that I need parse. The string is

  • 0

gcc 4.6.1 c89

I have a string that I need parse. The string is sdp information. I am trying to seperate each of the elements into seperate strings.

Basically the string would contain some thing like this:

v=0 o=sip_user IN 10230 22472 IP4 10.10.10.44 s=SIP_CALL c=IN IP4 10.10.10.44 m=audio 49152 RTP/AVP 0 8 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000

And I would like to seperate them into different strings. So this needs to be broken down into seperate strings.

str1 v=0 
str2 o=sip_user IN 10230 22472 IP4 10.10.10.44 
str3 s=SIP_CALL 
str4 c=IN IP4 10.10.10.44 
str5 m=audio 49152 RTP/AVP 0 8 
str6 a=rtpmap:0 PCMU/8000 
str7 a=rtpmap:8 PCMA/8000

I was trying to do something like this as a start. But even though it finds the v= I need to find when the next line will start.

char *str_v = NULL  
str_v = strstr(sdp_string, "v=");

if(str_v != NULL) {
    printf("found line: [ %s ]", str_v);
}

Many thanks for any suggestions,

  • 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-27T09:19:05+00:00Added an answer on May 27, 2026 at 9:19 am

    First, find the beginnings of all substrings (parts array below), then null terminate each of them. This is just to show how simple it can be to parse if the format is fixed.

    #include <stdio.h>
    #include <string.h>
    
    int main() {
            char input[] = "v=0 o=sip_user IN 10230 22472 IP4 10.10.10.44 s=SIP_CALL c=IN IP4 10.10.10.44 m=audio 49152 RTP/AVP 0 8 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000";
            char *parts[16] = {0};
            int top = 0;
            int i;
            char *s = input;
            while (top < 15 && (s = strchr(s, '='))) {   /* find each = and save a pointer to before it */
                    parts[top++] = s-1;
                    s++;
            }
            for (i = 1; parts[i]; i++)
                    parts[i][-1] = '\0';  /* null terminate each part */
            for (i = 0; parts[i]; i++)
                    printf("%s\n", parts[i]);
            return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

gcc 4.4.2 c89 I have a function that has to run (config_relays). It make
gcc 4.4.3 c89 I have the following string sip:12387654345443222118765@xxx.xxx.xxx.xxx How can I extract just
gcc 4.6.2 c89 I have the following 2D array that I want to pass
gcc 4.4.4 c89 I have a program that I am testing. I create a
gcc 4.5.1 c89 I have a buffer that is filled with char characters. I
gcc 4.4.2 c89 I have this code snippet that I have to repeat in
gcc 4.4.3 c89 I have some functions that initialize some hardware and return either
gcc 4.4.4 c89 I have the following code and 2 structures that have to
gcc 4.4.2 c89 I have a wave file: 8000 Hz 16 bit I am
gcc 4.4.2 c89 I have the following enum: enum drop_options_e { drop_ssm, drop_snm, drop_ssb

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.