std::Vector Segfault

I'm trying to populate a vector, which I've done hundred of times in other programs. For some reason I cant' pinpoint, I keep getting a segfault.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//Set number for num_nodes to 11 for degree 10 polynomial
        int num_nodes = 11;
        //Set interval and Create increment for each x value
        double a=0,b=2;
        double increment = (b-a)/num_nodes;

        //Create arrays to store x,y, and polynomial vals
        std::vector<double> nodes_arrayx(num_nodes,0);
        std::vector<double> nodes_arrayy(num_nodes,0);
        std::vector<double> polynomial(num_nodes,0);


        //Populate Node Arrays
        for(int i=0;i<num_nodes;i++)
        {
                nodes_arrayx[i] = a + (i*increment);
                nodes_arrayy[i] = exp(nodes_arrayx[i]);
                std::cout << "\nNode " << i << " (x,y) is: (" << nodes_arrayx[i] << ',' << nodes_arrayy[i]<<')';
//I added a second line here to verify this is where the segfault is. The second is an exact copy of  the first, but for some reason it causes segfault on i=10
                std::cout << "\nNode " << i << " (x,y) is: (" << nodes_arrayx[i] << ',' << nodes_arrayy[i]<<')';     


I isolated to the lines with std::cout, with the second being an exact copy of the first (as noted in code). Just before the segfault, it runs fine with the first line then stops.

Any ideas?
I can add that line in 5 times if I want, and it will print the first four and segfault on the last one but only when i = 10...

Really not sure what the problem is...
Nevermind. The problem was in a different part of my code. I'm just an idiot!

Lock this up please!
Topic archived. No new replies allowed.