ptr=strtok()
here ptr stores address of string
and then by just cout<<ptr why the address of the string is not printed ??? and how come the strings are printed.
String tokenizer 1
Hello @sharmalakshyarocks,
The << operator on std::cout is overloaded. Its behaviour depends on the type of the right operand. (It’s actually several different functions, all named operator<<; the compiler decides which one to call.)
- If you give it a char* or const char*, it treats the operand as a pointer to (the first character of) a C-style string, and prints the contents of that string:
\
const char * ptr = “hello”;
cout <<ptr; // prints “hello”
- If you give it a char value, it prints that value as a character:
\
cout << *ptr; // prints “h”
cout << ptr[0]; // the same
- If you give it a pointer of type void*, it prints that pointer value (in some implementation-defined way, typically hexadecimal):
\
cout << static_cast<const void*>(ptr); // prints something like 0x4008e4
Hope, this would help.
Give a like, if you are satisfied.