Вопрос

I am not able to return the nullptr at the end of this method? Is there some kind of library I need to import?

const char* strstr(const char* string1, const char* string2) {
    // TODO:
    for (int i = 0; i < strlen(string1); i++) {
        for (int j = 0; j < strlen(string2); j++) {
            if (string1[i] == string2[i]) {
                return &string1[i];
            }
        }
    }
    return nullptr;
}
Это было полезно?

Решение

nullptr is a feature introduced in c++11, see: What exactly is nullptr?. You'll need a compiler that supports at least some features of c++11.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top