문제

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