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...
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.