-1

How to write function that removes sub from string a?

For example if string is "Hi I am a noob very big noob" and sub is "noob". It would become "Hi I am a very big "

I think I must use strstr and strcat but how?

timgeb
  • 76,762
  • 20
  • 123
  • 145
  • What have you tried so far? The way you have formulated your question now you are very unlikely to get any help. Make an attempt and if you get stuck at a particular piece of the code come back for help – Pankrates Jun 06 '14 at 18:29

1 Answers1

1
  1. Find the length of the substring. Let's call it L.
  2. Find the position of the substring in the string A. Let's call it X.
  3. Create a new string from the concatenation of the first X characters of A and the characters of A found after position X+L.
ikegami
  • 367,544
  • 15
  • 269
  • 518