10-19-2018 02:00 PM
Hello,
I'm new in labWindows. I don't know how to show every values from array in Panel. I always get only one number. Im sorry for my ugly code. Please, help me.
int CVICALLBACK binary (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: GetCtrlVal(panelHandle,PANEL_wynik,tablica3); sscanf(tablica3, "%d", &t); int i=0; while(t) { tabInt[i++]=t%2; t=t/2; } for(int j=i-1; j>=0; j--) { g = tabInt[j]; sprintf(tablica3, "%ld", g); } SetCtrlVal(panelHandle, PANEL_wynik, tablica3); break; } return 0; }
10-21-2018 06:40 AM - edited 10-21-2018 06:43 AM
First of all, if you only want to display an integer number in binary format you can use the appropriate format show in the numeric control, as you can see here (this is not available for floating point numbers):
If you want to create it programmatically instead, the problem in your code is that your sprintf instruction every time replaces the existing content of the string with the new one. Try with this code instead:
sprintf (tablica3, "%s%ld", tablica3, g);
Finally, a simple search in the forum would have returned you a list of discussions with already solved similar questions to start with to solve your problem.