Original Post
How can i convert a char buffer to a float?
char buff[5]
float i = buff[5];
Trying to do that!
float i = atof(buff);
check
out
these
pictures
of
mine
#include <cstdlib>
#include <iostream>
int main ()
{
char buf[5];
strcpy (buf, "0.01");
float i = (float) atof (buf);
std::cout << i << std::endl; // prints 0.01
return (0);
}
case WM_COMMAND:
switch(LOWORD (wParam))
{
case IDOK:
char buffer[5];
GetDlgItemText(hwnd, IDC_EDIT1, buffer, 5);
float i= (float)atof(buffer);
g_Physics.GR.First = i;
EndDialog (hDlg, 0);
return TRUE;
break;
}
break;
}
quote:
Original post by BriTeg
the incredibly simple:
sscanf(mybuff, "%f", &myfloat);
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more