c++ - How can I mark the end of a C string? -
here code function:
void pattern(char word[200], char aspattern[200]) { (unsigned = 0; < strlen(word); i++) { // unsigned remove warning if (strchr("aeiou", word[i]) != 0) aspattern[i] = '*'; else aspattern[i] = '#'; }
basically function replaces consonants in word #'s , vowels *'s, , stores new pattern in aspattern string. however, if display aspattern on screen, shows correct pattern followed bunch of unknown symbols (strlen(aspattern) equals 211 or after loop). believe problem aspattern's end isn't marked , aspattern[strlen(aspattern)] = '/0' doesn't work , don't know else do...
i cannot use std::string, please bear me , use c strings.
add code
aspattern[strlen(word)] = '\0';
either before or after for-loop
Comments
Post a Comment