batee5a wrote:
well.....i did understand your replies partially.. but what happened
to me is that when i had used the function (strtok)
from the library <cstring>...i sent it a char* beside the delimiter
"."...as the following example
char * sentence="hai.bai.rasha";
cout<<strtok(sentence,".");
This produces undefined behavior because string literals are
non-mutable, and std::strtok attempts to change the contents of the
string argument (it adds NUL chars).
then an application error in a dialog box appeared....
as i know and as i read before...the (strtok)function do recieve a
char* and a const char* as arguments.....so why that erroe did
appear??and when i tried with an array instead ,it worked fine.....
Using an array allows the contents to be changed:
char sentence[] = "hai.bai.rahsa";
Note, however, that subsequent calls to std::strtok on the same logical
string should be made with a null source argument:
cout << std::strtok(0, ".");
See the recent thread "string tokenizing" for variations on string
tokenizing implementations:
http://groups.google.com/groups?thre...ail.com&rnum=1
/david
--
Andre, a simple peasant, had only one thing on his mind as he crept
along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
-- unknown