A Char * var used with math operators... what is ?
From c++ tutorial :
1 2 3 4
|
char str[] = "This is a sample string";
char * pch;
pch=strrchr(str,'s');
cout<<pch;
|
cout<<str; --- This is a sample string
cout<<pch-str+1; |
When do pch-str+1, we are working with pointers?
But cout<<pch; give me 'string'.
This is the normal behavior of char types?
Thanks
Last edited on
Both str and pch are actually pointers to char.
Pointers to chars are interpreted as null-terminated strings in output operations
Topic archived. No new replies allowed.