I'm having trouble figuring out why some of my integers are behaving crazy.(adsbygoogle = window.adsbygoogle || []).push({});

I have a vector of vectors, declared as

In another function, I add a vector of three ints to it usingCode (Text):vector<vector<int> > ph;

And later I try to print out the contents byCode (Text):vector<int> p;

p.push_back(0); p.push_back(0); p.push_back(1);

ph.push_back(p);

and it prints outCode (Text):int i;

for(i = 0; i < ph.size(); i++){

cout << ph[i][0] << " " << ph[i][1] << " " << ph[i][2] << endl;

} cout << endl;

0 0 0x633d50

where the last one seems to be a random hexadecimal number, or something.

Does anyone know why this might be happening? Some of my functions seem to be evaluating the third number correctly, and give me the proper result, while others seem to evaluate it as zero, and printing it out gives me gibberish.

Any help would be greatly appreciated.

Thanks in advance,

Devin.

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# C++ vector<vector<int> > problem

Loading...

Similar Threads - vector<vector<int> problem | Date |
---|---|

Fortran for Computational Fluid Dynamics Problems | Jan 11, 2018 |

Is it all in the angle? | Jan 3, 2018 |

Perceptron algorithm initial vector | Dec 28, 2017 |

Matrix times vector in Fortran | Jul 28, 2017 |

C/++/# Arrays/vectors without knowing type | Jun 19, 2017 |

**Physics Forums - The Fusion of Science and Community**