I'm a greenhorn when in comes to C++, but basically I'm trying to print an array with the following code:
#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include <numeric>
#include <math.h>
#include <iterator>
#include "rect_plate.h"
#include "numeric_constants.h"
using namespace std;
using std::vector;
// function prototypes
vector<double> generateRange(double a, double b, double c);
double lengthX;
double lengthY;
double resX;
double resY;
double Nx = lengthX / resX;
double Ny = lengthY / resY;
double deltaX = lengthX / Nx;
double deltaY = lengthY / Ny;
// function to calculate array
vector<double> generateRange(double a, double b, double c) {
vector<double> array;
while (a <= c) {
array.push_back(a);
a += b; // could recode to better handle rounding errors
}
return array;
}
vector<double> xSpace = generateRange(deltaX / 2, deltaX, lengthX);
vector<double> ySpace = generateRange(deltaY / 2, deltaY, lengthY);
int main()
{
// print array
for (int i = 0; i < Nx - 1; i++)
{
cout << "Test" << xSpace[i] << endl;
}
system("pause");
return 0;
}
but am not getting any output in the console when I run the executable file. All I get is 'press a key to continue' and then it exits the console.
I'm in the process of converting some of my procedural MATLAB into OO-C++. I had a class setup, with objects, but removed those for now to check if my variables were being initialized properly. I know in C#, there's a way to step through the code (F10 - I'm using VS2017), and when you hover the mouse over a given variable, it shows you the value, but haven't found anything similar for C++, so I'm just printing (or at least trying to print) everything for now.