I'm trying to write a function that extracts the comment out of a string. For example, given:
"this is a test //bread is great"
it returns:
"bread is great"
I've tried to count the characters until the first '//
' appears and then trim the unwanted part of the string.
while(s[i] != '/' && s[i+1] != '/') {
newbase++;
i++;
}
It worked for the first example but I'm having issues if I'm given a string like this:
"int test = 2/3"
It should return ""
(an empty string) but it doesn't. I don't understand it.