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

  • Home
  • SEARCH
  • 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 6020523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:34:53+00:00 2026-05-23T03:34:53+00:00

I need help as I am completely stuck here. Any idea for crictism will

  • 0

I need help as I am completely stuck here. Any idea for crictism will be very helpful.

I have string say ” cat-dog-animal”
and i want string like “dog-cat-animal”

I am slightly struck. I know in C i can use strtok , but that will break the string.
I AM wondering how to store that string in above format.

Thanks

  • 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-23T03:34:54+00:00Added an answer on May 23, 2026 at 3:34 am

    Treat the first 2/3 of the string as a ring buffer and rotate the characters in it.

    1. Find the index of the last dash
    2. Save char at index
    3. Move all preceding chars down one position
    4. Restore saved char in step 2 to front of string.
    5. Repeat steps 2 to 4 until the first dash is in the index position.

    Granted it is not the most efficient solution, but it does work.
    I’d post some actual code, but this sounds like homework.


    Edit

    #include <string.h>
    void function( char * s )
    {
        int second_dash = ( strrchr(s, '-') - s );
    
        do
        {
           char t = s[second_dash];
           memmove( s + 1, s, second_dash);
           s[0] = t;
        }
        while ( s[second_dash] != '-' );
     }
    

    If your string library doesn’t have strrchr() or memmove() they can be easily replaced by loops.

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

Sidebar

Related Questions

I'm completely stuck and need your help... I've created a webservice stub with jaxb
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
Ive been stuck on this for a while now so any help will be
I need help to replace all \n (new line) caracters for in a String,
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I am completely stuck on this issue so your help is greatly appreciated! I
need help for multiple screen support in android,I have done for 3.2 inch screen
Here's the deal: I have a heavy layout that cannot be improved any further,
i need to write a stored procedure which will return a string.logic is when
I am completely stuck on a drag and drop problem: I need to be

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.