Quote:
Originally Posted by nikhil.stephen
shudn't std::cout<<ptr[w] print the string following the char it is pointing to?
|
Could you explain this with some code? What is 'ptr'? How have you stored the string "abcdef"?
yy.cpp
Code:
#include <iostream>
using namespace std;
int main ()
{
char* dd = (char*)"abcdef";
cout << *dd << "\n";
cout << dd << "\n";
cout << *(dd+1) << "\n";
cout << dd+1 << "\n";
return 0;
}
Output:
Code:
anisha@linux-uitj:~> g++ -Wall -Wextra yy.cpp
anisha@linux-uitj:~> ./a.out
a
abcdef
b
bcdef