Think about what happens after you skip the first tag: you want to move the 7th character of line to the 1st position in tagless. In other words, the index values for the two strings will be different. So your logic needs to be something like:
1 2 3 4 5 6 7 8 9
for each position i in line
if (the i'th character in line is '<') {
increment i until the i'th character in line is '>'
} else {
set j'th character if tagless to i'th character in line
increment j
}
}
set j'th character of tagless to 0 (to null-terminate it).
Note a few things about this logic:
- It will work if you see adjacent tags <like><this>
- It will work if the string ends with a tag.
- It won't work for nested tags <like <this>>
- It won't work (and may crash) if a '<' doesn't have a matching '>'
The problem is lines 9-13. This appears to be where you're trying to do the part where I said "increment i until the i'th character is '>'."
So you actually need another loop here, not just an "if" statement.
Also tagless[i] = line[i] is wrong. The index for tagless will be different from the index for line. You need to keep track of both indexes. In my pseudocode I called them i and j.
You can add the null at the end of tagless the same way that you will add the other characters: tagless[j] = 0;