What will be the output of the following C++ code?

#include <iostream>
  using namespace std;
  int main()
  {
      char *ptr;
      char Str[] = "abcdefg";
      ptr = Str;
      ptr += 5;
      cout << ptr;
      return 0;
  }

a) fg
b) cdef
c) defg
d) abcd

1 thought on “What will be the output of the following C++ code?”

Leave a Comment