Thanks Akarui, it works great with the string class. I was hoping to understand the pointer arrays, and mem allocation, but it seems finding ways around the problem is usually easier than understanding what the problem really is...
I have the following code, and am trying to read in a character string from the keyboard, and save it as the name of the vector... but as you can see from the output, the input is saved until the next cin statement, at which time the name is switched to 2!! I imagine it is some pointer problem...
Thanks, that clears alot up... I was thinking of the array as a list of pointers randomly thrown wherever there was space on the heap, but now that I see that the pointers are all in one memory block with consecutive addresses, it all makes sense... I will make sure that I keep an eye on the...
I'm using viz studio 6 (shouldn't matter, but fyi), and am kind of curious why this works...
#include<iostream>
#using namespace std;
int main(int argc, char* argv[])
{
int *p;
p = new int[10];
for (int i=0;i<10;i++)
p = i;
// curiosity lies here, i increases out of the domain...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.