Ques..??

This is a discussion on Ques..?? within the C++ Programming forums, part of the General Programming Boards category; Let's say I have an array with ten values inside of it, and i delete the one in the middle. ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    16

    Ques..??

    Let's say I have an array with ten values inside of it, and i delete the one in the middle. How can i get the one after middle to go in the middle and get rid of the space in between the 2 half...
    ??
    Thanx

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    this is assuming your using a null-terminated (C-Style) string:

    Code:
    int index=5; //the char you will be deleting
    int stringLength=strlen(yourCstring)-1; // <cstring>
    
    for(index;index<stringLenghth;index++) //loop from where you deleted to the end
          yourCstring[index]=yourCstring[index+1];  //replace it with the next value
    
    yourCstring[index+1]='\0'; //terminate the string
    you can do the same thing with arrays if you know how many values are in it... you can modify this code to do what you want...
    Last edited by major_small; 03-13-2004 at 08:43 PM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need the code of few programs in c++.plzzzzz help...plzzz
    By NAVINKR20 in forum C++ Programming
    Replies: 1
    Last Post: 05-08-2009, 09:13 AM
  2. Short ques
    By Zionaster in forum C++ Programming
    Replies: 4
    Last Post: 07-11-2003, 04:38 AM
  3. simple rand() ques.
    By Beginner2002 in forum C Programming
    Replies: 1
    Last Post: 07-28-2002, 05:42 PM
  4. ques
    By tim in forum C Programming
    Replies: 1
    Last Post: 04-22-2002, 10:06 AM
  5. ques on what to focus on?
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 04-19-2002, 11:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21