Thread: Beginners question about arrays/strings

  1. #1
    Registered User
    Join Date
    Nov 2005

    Beginners question about arrays/strings

    Lets say I have a string of characters, and I want to cut out the nth character.

    Eg I want to turn 'world' into 'word' or 'wrld'

    How do I do this?

    I have tried saying that if blah[x] == blah[x+1], then do a loop which then proceeds to do blah[x]=blah[x+1] until x==n(when n is the number of letters in the word + 1). Unfortunately, despite trying this with both for and while loops i had no sucess.

    Thanks for any advice

  2. #2
    Registered User
    Join Date
    Oct 2001
    Here's one way.
       char a[] = "world";   
       char b[80] = "";
       strncpy(b, a, 3);
       strcat(b, a+4);
       printf("%s\n", b);

  3. #3
    Registered User TactX's Avatar
    Join Date
    Oct 2005
    What about taking a look at memmove()

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner's Question on QT
    By unix7777 in forum C++ Programming
    Replies: 1
    Last Post: 11-30-2008, 04:53 PM
  2. beginner's question :D
    By kingliaho in forum C Programming
    Replies: 5
    Last Post: 10-17-2008, 05:20 PM
  3. beginner's question about C
    By Roberto Llovera in forum C Programming
    Replies: 5
    Last Post: 02-26-2004, 04:14 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM