I want to generate a random number with SimuTemp and save it into my messarray, same with zahler. But I just couldn't find out how I do that. I've tried printing the array out just to check if it works but it just added new random values and didnt save the old ones.
typedef struct
{
double SimuTemp(double x) //Random-Temperatur-Generator von Zahlen zwischen -200 und 800
{
x = ((double)rand() / (double)RAND_MAX); // Erzeugt "zufällige" double Werte im Bereich zwischen 0.0 und 1.0
x = x * 1000;
x = fmod(x, 1000);
x = x - 200;
return x; // Gibt den Wert der in x steht zurück
};
int zahler;
time_t secs;
}Messwert;
typedef struct
{
Messwert messarray[3];
time_t currenttime;
}Messreihe;
int main()
{
double x= 0;
srand(time(NULL));
Messreihe M1;
Messreihe *PointerM1;
PointerM1 = (Messreihe*)malloc(sizeof(Messreihe)* 1);
if (PointerM1 != NULL){ free(PointerM1); }
M1.messarray[0].zahler = 0;
for (int i = 0; i < 3; i++)
{
M1.messarray[i].zahler = M1.messarray[i].zahler + 1;
printf("Messwerte[%i]:%.1f \n", M1.messarray[i].zahler, M1.messarray[i].SimuTemp(x));
}
_getch();
}
Aucun commentaire:
Enregistrer un commentaire