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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:47:15+00:00 2026-05-26T15:47:15+00:00

Actually I need to handle situation like I should be giving input as rows

  • 0

Actually I need to handle situation like

I should be giving input as rows <n>
There should be space between ‘rows’ and number <n> or any single non numeric character.

I should be able to separate that string part and assign it to a char variable and number part to a int…

The string part should be then verified whether its a correct command or not.. If a wrong command is entered like “ada aad 99” or “adaha 9” or “adfad9”.. It should say “its wrong command”.

I tried to use strtok(), but it can’t handle strings where there isn’t NULL in between strings.. I tried to use $ sscanf(string,"%s %*c %d",str, &num);
but its even not working for all possibilities.

How can I do it?

  • 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-26T15:47:16+00:00Added an answer on May 26, 2026 at 3:47 pm

    I don’t see your problem with strtok, it would be perfect in this case I think.

    In pseudo-code:

    line = getline();
    split_line_into_tokens(line);
    if tokens[0] == "command1" {
        if tokens_num > 2 {
            error("to many arguments to command1");
        } else if tokens_num < 2 {
            error("command1 needs one argument");
        } else {
            do_command_1(tokens[1]);
        }
    } else {
        error("unknown command");
    }
    

    In the above pseudo-code, split_line_into_tokens() uses strtok to create an array of tokens, using space as the separator. If strtok returns an empty string (not NULL) then there is more than one space used and you skip that. The split_line_into_tokens creates the tokens array, which first entry contains the command, and the remaining contains the arguments. The variable tokens_num is set to the number of tokens in the array.

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

Sidebar

Related Questions

I'm trying to handle Winsock_Connect event (Actually I need it in Excel macro) using
I'm getting pretty big input string into my method, but what I actually need
I need a table where rows are actually 2 rows tables, a nested table
Why do we actually need to handle DragEnter event of the drop destination? What
Let's say, hypothetically (read: I don't think I actually need this, but I am
I need a help from ur side. Actually I need to call a method
Actually We are doing thesis work where we need to make 10 voip phones
I need to get just the first item (actually, just the first key) off
I need to getting the client ip address using javascript.Actually,our connection provider ip is
I need to check whether a page is being redirected or not without actually

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.