Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将 3 个字符(“123”)的 char * 字符串转换为带两位小数的浮点数(1.23)。
您可以使用 atoi,它将 ASCII 转换为整数。然后将该 int 转换为浮点数。
int num = atoi(string); float f = num/100.0f; printf ("%.2f", f);