Crash_Override Crash_Override - 1 year ago 45
C++ Question

How do I find the memory address of a string?

I am having a mental block and I know I should know this but I need a little help.

If I declare a string variable like this:

string word = "Hello";

How do I find the memory address of "Hello"?

Edit: This is what I am trying to do...

Write a function that takes one argument, the address of a string, and prints that string once. (Note: you will need to use a pointer to complete this part.)

However, if a second argument, type int, is provided and is nonzero, the function should print the string a number of times equal to the number of times that function has been called at that point. (Note that the number of times the string is printed is not equal to the value of the second argument; it is equal to the number of times the function has been called so far.)

Answer Source

Use either:


Note that the pointer returned by either of these calls doesn't have to be the underlying data the std::string object is manipulating.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download