Hi everyone,
I have the following code which is not working (always gives an output of zero):
Code:
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT2));
int len2 = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT4));
char* buf;
char* buf2;
buf = (char*)GlobalAlloc(GPTR, len + 1); //Mass
buf2 = (char*)GlobalAlloc(GPTR, len2 + 1); //Radius
GetDlgItemText(hwnd, IDC_TEXT2, buf, len + 1);
GetDlgItemText(hwnd, IDC_TEXT4, buf2, len2 + 1);
Third=G*atof(buf);
Fourth=atof(buf2)*1000;
First=Third/Fourth;
Second=First/1000;
char strFirst[100];
sprintf_s(strFirst,"%0.2f", Second);
SetDlgItemText(hwnd, IDC_TEXT3, strFirst);
I have noticed that when I change "First=Third/Fourth" to "First=Third*Fourth" it produces a non-zero result. What is the problem with using the "/"?
Thanks.