following lines were in the video:
char *ptr;
ptr=strtok(str," ");
cout<<ptr;
- why does cout<<ptr; gives return value of the function instead of an address.
- pointer should point to an address s??
following lines were in the video:
char *ptr;
ptr=strtok(str," ");
cout<<ptr;
hey abhishek, yes pointer variable are for storing address only. But whenever you use char pointer with cout, it will give you value instead of address.It is because of operator overloading of << operator.
cout works fine other datatype, it will give address only that stored by pointer. You can check it.
int a=10;
int *ptr;
ptr=&a;
cout<<a; //output will be address of a only