Thread: A method to deleted a substring from a string

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2022
    Posts
    2

    A method to deleted a substring from a string

    Hello, I am trying to delete a substring from a string. I am trying to use pointers and return the value where the substring occurrence is found. But I am lost. Here is what I have so far ----

    Code:
    int delete_substring(char *str, char *substr)
    {
      int i;
      char *position = strstr(str, substr);
      if (!position)
        return -1;
      return position - str;
    }
    Last edited by Salem; 10-21-2022 at 11:08 PM. Reason: Removed crayola

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating insert substring method?
    By glasgow in forum C Programming
    Replies: 1
    Last Post: 10-21-2022, 06:44 PM
  2. How to enter new value to a deleted string
    By sumanthyj in forum C Programming
    Replies: 1
    Last Post: 02-19-2019, 10:39 PM
  3. Substring of a string
    By LotusE in forum C Programming
    Replies: 2
    Last Post: 01-23-2006, 03:36 PM
  4. substring in string
    By kenni81 in forum C Programming
    Replies: 1
    Last Post: 02-03-2003, 06:05 PM
  5. seeing if there is a substring in another string
    By canine in forum Windows Programming
    Replies: 2
    Last Post: 12-05-2001, 04:43 AM

Tags for this Thread