I'm a beginner in C and after long time and effort I finished my 1500 rows code in C. It was running perfectly and producing results as expected, but when I tried to add more input than the tests I faced a breakdown.
More specifically, I managed to find the source of the problem in the struct array.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#define ROWS 5000
#define MAXLOGGERS 26
struct data
{
int day;
int month;
int year;
int hour;
int minute;
int second;
float value;
float temp;
float hum;
};
int main()
{
printf("Enter the number of loggers that you want to import: ");
int n = 10;
while (n > MAXLOGGERS)
{
printf("You can input data from maximum %d loggers: ", MAXLOGGERS);
scanf("%d", &n);
}
struct data mydata[n+1][ROWS];
printf("\n\nSuccess!!\n");
}
Now when I use n = 10 or less, the program finishes as expected. When I change n to 11 or more it crashes.
I'm suspecting something is wrong with the declaration of the struct array, but I can really not figure it out.
Any help would be more than welcome! Thanx (: