#include <curses.h>
#include <stdafx.h>
double Array[10];
int x;
int main ()
{
initscr();
printw("Extracting value from loop\n\n");
Array[5]=12345;
for (x=0; x++; x<10)
{
Array[x]=1;
printw("Array %d value is now %f\n\n",x, Array[x]);
Sleep(200);
refresh();
}
printw("Value extracted is: %f\n\n",Array[5]);
refresh();
getch();
endwin();
return 0;
}
My first problem is that the "for" loop for some reason is not working, the program just skips it (?!), why that ?
My second issue is that, even if the "for" loop is working, for some reason the
"printw("Value extracted is: %f\n\n",Array[5]); " command instead of returning 1, is still returning 12345.
In other terms I don't know how to make a reference, in an command that is outside the "for" loop, to an array whose results are feeded by this same loop.
also, note that Array[x]=1; would be effectively setting all of the values in the array to 1, which, with the for loop working correctly, would explain the behavior when printing Array[5].