I'm pretty new to C and am trying to do what I assume is very simple - but am getting stuck for some reason:
I have a main in a file called runnable.c where I have:
#include <stdio.h>
#include <windows.h>
#include "utils.h"
#define N 100000
#define num_vars 1
int main() {
printf("I am running...\n");
double values[N*num_vars];
double ders[N*num_vars];
char variable[] = "params.txt";
read_file_to_array(variable, values); // fills up values
test_values(values);
test_num_points(N);
test_ders(ders);
return 0;
}
I then have utils.h which defines
void test_values(double values[]);
void test_ders(double ders[]);
void test_num_points(int num_points);
And utils.c which has
#include <stdio.h>
void test_values(double values[]) {
printf("I am in test_values\n");
}
void test_num_points(int num_points) {
printf("I am in test_num_points\n");
}
void test_ders(double ders[]) {
printf("I am in test_ders\n");
}
I'm compiling on my Windows machine using
cl runnable.c utils.c /link /out:program.exe
Everything works great when I just have test_values and test_num_points - but for some reason it doesn't run successfully when when I add test_ders into the mix. It still compiles correctly, but nothing is outputed.
I'm having trouble getting the debugger to work on my Windows machine and was hoping somebody might be able to help me figure out what's going on.
double ders[100000*1]uses 800Kbytes, so that's a bit big for a local variable. You can declare with thestatickeyword, or move it out ofmain(i.e. make it a global variable).staticand global variables can use all of the memory, so they can be much bigger than local variables.