Files
seer/tests/helloarray/helloarray.cpp
T
Ernie Pasveer 2bd3280de8 Tweak memory/array visualizer.
Make number of bytes default to 256. Can be changed if needed.
Change to 'Variable expression'.
Show results immediately.
2022-05-15 13:32:00 -05:00

83 lines
1.2 KiB
C++

#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <iostream>
float* function1() {
float* float_array = (float*)malloc(256);
for (int i=0; i<64; i++) {
float_array[i] = (float)i * 1.13;
}
return float_array;
}
int main (void) {
//
//
//
char* array = (char*)malloc(256);
for (int i=0; i<256; i++) {
array[i] = i;
}
//
//
//
int* int_array = (int*)malloc(256);
for (int i=0; i<64; i++) {
int_array[i] = i*0;
}
//
//
//
float* float_array = (float*)malloc(256);
for (int i=0; i<64; i++) {
float_array[i] = (float)i * 1.13;
}
//
//
//
int table_size = 512;
double two_pi = (3.14159 * 2);
float phaseIncrement = two_pi/table_size;
float currentPhase = 0.0;
float* sine_array = (float*)malloc(table_size*sizeof(float));
for (int i = 0; i < 512; i ++){
sine_array[i] = sin(currentPhase);
currentPhase += phaseIncrement;
}
//
//
//
float* x = function1();
//
//
//
printf("Hello array!\n");
free(array);
free(int_array);
free(float_array);
free(sine_array);
free(x);
return 0;
}