-2

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;
}
letter Q
  • 14,735
  • 33
  • 79
  • 118

1 Answers1

4

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.

Community
  • 1
  • 1
Peter Clark
  • 2,863
  • 3
  • 23
  • 37