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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:46:07+00:00 2026-06-03T03:46:07+00:00

I have a problem in C while parsing the argv Variable. This is the

  • 0

I have a problem in C while parsing the argv Variable. This is the task:

I got some Parameters form the Command line into my C programm. One of them looks like “-r=20-5”. There I have to find the “r”. this works with:

if (argv[i][0] != 0 && argv[i][1] != 0 && argv[i][2] != 0 &&
    argv[i][0] == '-' && argv[i][2] == '=') { /* Check the Variables */
    switch (argv[i][1]) {
        case 'r':
            /* what have to be here? */
            break;
}

Now I have the “r”. But I need the 20 and the 5 in two different variables too. Here is what i thougt about, but it did’t work. I tried something with

strsep(argv[i]+3, "-");

But my Compiler (Xcode) throws a warning (warning: passing argument 1 of ‘strsep’ from incompatible pointer type)

Does anyone has any idea (or link) how I can solve the problem?


After it’s solved there was still a warning, so I was answered to post my entire new code:


int parse(int argc, const char *argv[]) {
    int i, x, y;
    int intTmp;
    long longTmp;
    char *strTmp;
    char *end;

    for (i = 1; i < argc; i++) {
        /* check for (-?=) */
        if (argv[i][0] != 0 && argv[i][1] != 0 && argv[i][2] != 0 &&
            argv[i][0] == '-' && argv[i][2] == '=') {

            /* IGNORE THIS
             * longTmp = strtol(argv[i]+3, &end, 10);
             * intTmp = analyseEndptr(longTmp, argv[i]+3, end);
             */

            switch (argv[i][1]) {
                case 'r':
                    strTmp = argv[i]+3;                 /* <= Here I got the warning */
                    x = atoi(strsep(&strTmp, "-"));
                    y = atoi(strsep(&strTmp, "-"));
                    printf("x=%d, y=%d\n", x, y);
                    break;
            }
        }
    }
}

The warning is: warning: passing argument 1 of ‘strsep’ from incompatible pointer type

My compiler is: gcc on MacOS using XCode as IDE

  • 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-03T03:46:08+00:00Added an answer on June 3, 2026 at 3:46 am

    Do you know sscanf? Have a look at:

      unsigned a,b;
      if( 2==sscanf(argv[i],"-r=%u-%u",&a,&b) )
        printf("%u-%u",a,b);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem while loading a UITableView on UITabBarController, i got this error
I have some problem with JSON parsing. When I hit URL, I've got JSON
I have a problem related to parsing a SOAP message. This is the message:
I've got a problem while parsing a OWLS Document (RDF) with Jena. The document
I recently stumbled across this problem while testing my C# program. parsing ) -
i have a problem while building and running an iphone application.Im using xml parsing
OK suppose I'm parsing some XML (the problem exists while reading any language but
My team and I have this nasty problem with parsing a string received from
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have a problem while converting a string whose value is dd.mm.yyyy to DateTime

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.