How do you go about reading a string from memory when you only have the pointer. For example &ptr is 0x7ffeb7ec2328. How can I read from this pointer location to the end of the string?
char *duh; //a character pointer.
duh = new char[100];
sprint(duh, "I am a string");
&duh; // a pointer to a pointer. This isn't a reference, its the address of the pointer, which is the same as char ** … you can't do anything useful with this.
you may actually have a reference.. you can ignore that as far as accessing it goes:
void foo(char *&wtf)
cout << wtf << endl; //the & just lets you modify the pointer itself, which might be useful if you wanted to destroy the old one and make a new one with length 200 instead.
char* IS a string.
you can write it:
cout << duh << endl;
you can read it
cin >> duh;
you can play with its characters individually
for(I = 0; I < strlen(duh); I++)
duh[I] = 'x';