I am on an IOS project and we use objective-c.
I function passes some data with type const char*. I can view the data in the debugger:
expr -- (void)printf("[%s]\n",(const char *)xml)
but I would like to change the value of the xml variable on the fly via the debugger. How can be done?
The same way you would do for char*
:
For const char *xml = "<xml></xml>";
you can assign to xml with
expr -- xml = "<foo></foo>"
Of course xml
(The pointer to your string) is in the functions scope, so you only change where xml
in the function is pointing to, not the string that xml
originally points to (which you can't, beacause you have a pointer to const
)
This does not work if xml
is declared as char xml[] = "<xml></xml>";
, because arrays are not assignable in C.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.