I’m looking to insert a HTML string tag into another string before the punctuation.
i.e. Given “Robert:”, I would like to output “Robert:”
Currently I have (apart of a function):
#define fhighlight "<font_color="red"><b>"
#define bhighlight "</b></font>"
#define punct ".,;:!?"
#define wordlen 15
char w[wordlen];
w = "Robert:";
w = strcat(fhighlight,w);
if ((strchr(punct,w)==1) { /*check for punctuation in w*/
/*not quite sure what to put here*/
} else {
w = strcat(w,bhighlight);
}
Any help will be greatly appreciated.
strchr() only looks for one character at a time (and you aren’t calling it correctly), so would need to be called in a loop for each character in punct. Here is one function to look for any of them. Also, you are not using strcat() correctly.