CString to float/float to Byte/Byte to Float
C++/MFC 2020. 10. 15. 14:281 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | void CMFCApplication1Dlg::OnBnClickedButton1() { CString strTest; //CString to float CString str; GetDlgItemText(IDC_EDIT1, str); float f = _tstof(str); strTest.Format(_T("%.4f"), f); AfxMessageBox(strTest); //float to Byte unsigned char* upt; int iCnt; upt = (unsigned char*)&f; strTest.Format(_T("%02X, %02X, %02X, %02X"), upt[3], upt[2], upt[1], upt[0]); AfxMessageBox(strTest); //Byte to float unsigned char b[] = { upt[0], upt[1], upt[2], upt[3] }; //4byte memcpy(&f, &b, sizeof(float)); strTest.Format(_T("%.4f"), f); AfxMessageBox(strTest); } | cs |
//참고
//CString to float
https://docs.microsoft.com/ko-kr/cpp/c-runtime-library/reference/atof-atof-l-wtof-wtof-l?view=vs-2019
//float to Byte
https://zapiro.tistory.com/entry/4-byte-float-format-float-%ED%98%95%EC%9D%98-%EC%8B%A4%EC%88%98-%EC%A0%80%EC%9E%A5-%EB%B0%A9%EC%8B%9D
//Byte to float
'C++ > MFC' 카테고리의 다른 글
프로젝트에 리소스로 PNG파일 추가 (0) | 2021.05.13 |
---|---|
MFC 강의, 참고 (0) | 2020.09.17 |