[Solved] Please help me correcting this code [closed]


Suggest you to debug it using debugger. Number of issues like

  • ptr1 != '0' should be *ptr1 != '\0' as one stage your loop should fail & it happen by comparing value(*ptr) on that address not by comparing address(ptr).
  • in for loop initialization part ptr1 = &name is wrong it should be ptr1 = name

Here is the code you might want

for (ptr1 = name; *ptr1 != '\0'; ptr1++) {
      for (ptr2 = ptr1; *ptr2 != '\0'; ptr2++) {
            cout << *ptr2;
      }
      cout << ' ';
}

1

solved Please help me correcting this code [closed]