Thread: String Prob

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    4

    Unhappy String Prob

    I would like to know how do u get to the end of the string, copy the remainding characters then pasting it to the front of the string without overwriting it. Thanks =)

  2. #2
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    IF u are already at the end of a string, what are the remaining characters?

    One way is to move all the characters down along the array. ALternatively, a more complicated and better way ( not if u're making something simple ) is to use linked lists.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    4

    Wink

    The remaining characters I was talking about was in the middle of the string ...... =)

    eg.
    Input = hello
    value = 4
    output = elloh

    This is y I want to know how 2 get to the end of the string and bring it to the front.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    4
    Can the code help you?
    Code:
    	tmp = str[0];
    	for(i = 0;i < strlen(str) - 1;i++)
    		str[i] = str[i + 1];
    
    	str[strlen(str) - 1] = tmp;
    
    	str[strlen(str)] = '\0';

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM