I am trying to set up and use an array in c++. The array has been declared and been used, but I keep getting back the error "variable set but not used", even though I have used it in the program.
It works on Linux but not Windows 10.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int sampling_rate = 44100;
double dt = 1.0 / sampling_rate;
int duration = 1;
int number_of_samples = duration / dt;
int sample_array[number_of_samples];
int amplitude = 5000;
cout << "sampeling rate = " << sampling_rate<<endl;
for (int sample_number = 0; sample_number < sampling_rate; sample_number++)
{
double sample_time = sample_number * dt;
sample_array[sample_number] = amplitude * sin(2 * M_PI * 293 * sample_time);
}
}
I expect this code to make an array that can then be converted to a sine wave.