School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

C Source Code


Welcome to Dream.In.Code
Become an Expert!

Join 340,116 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,303 people online right now. Registration is fast and FREE... Join Now!




Deleting Selected Set of Characters from a String

This Code Snippet shows how a given set of characters can be deleted from a string.

Submitted By: born2c0de
Actions:
Rating:
Views: 1,622

Language: C

Last Modified: March 20, 2007

Snippet


  1. /*
  2.    X = Source String
  3.    n = Number of Characters to be deleted
  4.   pos= Position to Start Deleting Characters
  5. */
  6.  
  7. #include <string.h>
  8.  
  9. int delchar(char *X,int n,int pos)
  10. {
  11.      if((n+pos-1)<=strlen(X))
  12.    {
  13.      strcpy(&X[pos-1],&X[n+pos-1]);
  14.      return 1;   /* SUCCESS */
  15.    }
  16.    else
  17.         return 0;   /* String Smaller */
  18. }

Copy & Paste


Comments

There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month