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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:24:04+00:00 2026-05-12T15:24:04+00:00

Could find a similar thing for C here. I need to break a sentence

  • 0

Could find a similar thing for C here.

I need to break a sentence into a an char array based on occurrence of a character example: %

Example

If my sentance is my%healthy%dog then i should be able to get my, healthy and dog separately.
This could be in a loop as well.

tx

  • 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-12T15:24:04+00:00Added an answer on May 12, 2026 at 3:24 pm

    strtok is the standard C function to achieve string tokenizing.

    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
            char c[] = "my%healthy%dog";
            char *token = strtok(c, "%");
            while (token != NULL)
            {
                    printf("%s\n", token);
                    token = strtok(NULL, "%");
            }
            return 0;
    }
    
    
    $ ./a.exe
    my
    healthy
    dog
    

    Also note that strtok uses static variables internally, so it is not threadsafe. For threadsafety, you’ll have to use the strtok_r function.

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

Sidebar

Related Questions

I went through answers on similar topics here on SO but could't find a
I have looked for similar questions, but could find none other than the difference
I reviewed similar questions but could not find an answer to my specific quandry.
I've tried looking at similar problems, but could not easily find one that helped
I couldn't find anything similar to this anywhere. I have an array of pointers
I've looked around here for similar question but couldn't find any that solved my
I suppose similar problem would have been discussed here, but I couldn't find it.
I know there are already several similar questions here, but I need some recommendations
I bet that I could find the answer of this question from reading similar
I tried searching for this but couldn't find a similar question. I have a

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.