I'm new to c / c BUT not new to programing, I know php vary well. Well, on to my question. I'm writing a physics calc, the user enters a Vi and Angle and it gives them the rest of the info, here's my php version. I got my c one to work BUT it cuts everything past the decimal off... If some one could show me how to get it to not cut them off if it is I dint know what I would do.

case IDC_GO:
{
	float y, x, h, t, j, l;
	float pi = 3.14159265359;
				
	float vi = GetDlgItemInt(hwnd, IDC_VITEXT, NULL, FALSE);
	float a = GetDlgItemInt(hwnd, IDC_ANGLETEXT, NULL, FALSE);

	a = ( a / 1 ) * ( pi / 180 );

	y = vi * sin(a);
        x = vi * cos(a);
			
	h = -y / -9.81;
	t = h * 2;
			
	j = ( y * h ) + ( -4.905 * pow(h,2) );
	l = x * t;
	
	a = ( a ) * ( 180 / pi );

	SetDlgItemInt(hwnd, IDC_VITEXT, vi, TRUE);
	SetDlgItemInt(hwnd, IDC_ANGLETEXT, a, TRUE);
	SetDlgItemInt(hwnd, IDC_VXITEXT, x, TRUE);
	SetDlgItemInt(hwnd, IDC_VYITEXT, y, TRUE);
	SetDlgItemInt(hwnd, IDC_TIMETEXT, h, TRUE);
	SetDlgItemInt(hwnd, IDC_FULLTIMETEXT, t, TRUE);
	SetDlgItemInt(hwnd, IDC_HEIGHTTEXT, j, TRUE);
	SetDlgItemInt(hwnd, IDC_LENGTHTEXT, l, TRUE);
}
break;

Heres a link the the .exe

I would say that you just need to set the precision and/or the fixed notation. The setprecision and fixed manipulators can be set and all floating point output will use this format until you choose different formats. So, if you have the following:

double Pi = 3.1429
cout << setprecision(2) << fixed;
cout << Pi << endl;
cout << Pi << endl;
cout << setprecision(4);
cout << Pi << endl;

The output should look like this:
3.14
3.14
3.1429

Other options to fixed notation include scientific, etc. To use these format manipulators, you will need to include <iomanip>. Older compilers may not recognize cout << fixed even with this file included. If this happens, use
cout << setiosflags(ios::fixed);
setprecision will not affect integers so, watch for integer division. I cannot get to your exe code, but the lack of decimal digits could be because an output for an int / int will be an int. A solution for this is to multiply the result by 1.0 before outputting. Hope this helps.

well... I dont think that useing cout is going to work when im inclueding windows.h and math.h right now. I think what needs to be done is find a way a can get the SetDlgItemInt to "setprecision(10)" or somthing like that.

I got it to work!

Fix:

#define BUFFER 14

TCHAR tchBuffer[BUFFER];

SetDlgItemText(hwnd, IDC_HEIGHTTEXT, _gcvt(j, 13, tchBuffer));
SetDlgItemText(hwnd, IDC_LENGTHTEXT, _gcvt(l, 13, tchBuffer));

Can you tell me clearly about GetDlgItemInt funtion in Window program with Visual studio 2005. I did like above, but returned value is always zero.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.